Documentation
¶
Index ¶
- func NewRemoteLedgerFactory(grpcAddr string, logger zerolog.Logger, maxRequestSize, maxResponseSize uint) ledger.Factory
- type Client
- func (c *Client) Close() error
- func (c *Client) Done() <-chan struct{}
- func (c *Client) Get(query *ledger.Query) ([]ledger.Value, error)
- func (c *Client) GetSingleValue(query *ledger.QuerySingleValue) (ledger.Value, error)
- func (c *Client) HasState(state ledger.State) bool
- func (c *Client) InitialState() ledger.State
- func (c *Client) Prove(query *ledger.Query) (ledger.Proof, error)
- func (c *Client) Ready() <-chan struct{}
- func (c *Client) Set(update *ledger.Update) (ledger.State, *ledger.TrieUpdate, error)
- func (c *Client) StateByIndex(index int) (ledger.State, error)
- func (c *Client) StateCount() int
- type ClientOption
- type RemoteLedgerFactory
- type Service
- func (s *Service) Get(ctx context.Context, req *ledgerpb.GetRequest) (*ledgerpb.GetResponse, error)
- func (s *Service) GetSingleValue(ctx context.Context, req *ledgerpb.GetSingleValueRequest) (*ledgerpb.ValueResponse, error)
- func (s *Service) HasState(ctx context.Context, req *ledgerpb.StateRequest) (*ledgerpb.HasStateResponse, error)
- func (s *Service) InitialState(ctx context.Context, req *emptypb.Empty) (*ledgerpb.StateResponse, error)
- func (s *Service) Prove(ctx context.Context, req *ledgerpb.ProveRequest) (*ledgerpb.ProofResponse, error)
- func (s *Service) Set(ctx context.Context, req *ledgerpb.SetRequest) (*ledgerpb.SetResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRemoteLedgerFactory ¶
func NewRemoteLedgerFactory( grpcAddr string, logger zerolog.Logger, maxRequestSize, maxResponseSize uint, ) ledger.Factory
NewRemoteLedgerFactory creates a new factory for remote ledger instances. maxRequestSize and maxResponseSize specify the maximum message sizes in bytes. If both are 0, defaults to 1 GiB for both requests and responses.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements ledger.Ledger interface using gRPC calls to a remote ledger service.
func NewClient ¶
NewClient creates a new remote ledger client. grpcAddr can be either a TCP address (e.g., "localhost:9000") or a Unix domain socket. For Unix sockets, you can use either the full gRPC format (e.g., "unix:///tmp/ledger.sock") or just the absolute path (e.g., "/tmp/ledger.sock") - the unix:// prefix will be added automatically. Options can be provided to customize the client configuration. By default, max request and response sizes are 1 GiB.
func (*Client) Done ¶
func (c *Client) Done() <-chan struct{}
Done returns a channel that is closed when the client is done. This cancels any in-flight gRPC calls and closes the connection. The method is idempotent - multiple calls return the same channel.
func (*Client) GetSingleValue ¶
GetSingleValue returns a single value for a given key at a specific state.
func (*Client) InitialState ¶
InitialState returns the initial state of the ledger.
func (*Client) Ready ¶
func (c *Client) Ready() <-chan struct{}
Ready returns a channel that is closed when the client is ready. For a remote client, this waits for the ledger service to be ready by calling InitialState() with retries to ensure the service has finished initialization.
func (*Client) Set ¶
Set updates keys with new values at a specific state and returns the new state.
func (*Client) StateByIndex ¶
StateByIndex returns the state at the given index. -1 is the last index. This is not supported for remote clients as it requires gRPC methods that are not yet implemented.
func (*Client) StateCount ¶
StateCount returns the number of states in the ledger. This is not supported for remote clients as it requires gRPC methods that are not yet implemented.
type ClientOption ¶
type ClientOption func(*clientConfig)
ClientOption is a function that configures a Client.
func WithCallTimeout ¶
func WithCallTimeout(timeout time.Duration) ClientOption
WithCallTimeout sets the timeout for individual gRPC calls.
func WithMaxRequestSize ¶
func WithMaxRequestSize(size uint) ClientOption
WithMaxRequestSize sets the maximum request message size in bytes.
func WithMaxResponseSize ¶
func WithMaxResponseSize(size uint) ClientOption
WithMaxResponseSize sets the maximum response message size in bytes.
type RemoteLedgerFactory ¶
type RemoteLedgerFactory struct {
// contains filtered or unexported fields
}
RemoteLedgerFactory creates remote ledger instances via gRPC.
type Service ¶
type Service struct {
ledgerpb.UnimplementedLedgerServiceServer
// contains filtered or unexported fields
}
Service implements the gRPC LedgerService interface
func NewService ¶
NewService creates a new ledger service
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, req *ledgerpb.GetRequest) (*ledgerpb.GetResponse, error)
Get returns values for multiple keys at a specific state
func (*Service) GetSingleValue ¶
func (s *Service) GetSingleValue(ctx context.Context, req *ledgerpb.GetSingleValueRequest) (*ledgerpb.ValueResponse, error)
GetSingleValue returns a single value for a given key at a specific state
func (*Service) HasState ¶
func (s *Service) HasState(ctx context.Context, req *ledgerpb.StateRequest) (*ledgerpb.HasStateResponse, error)
HasState checks if the given state exists in the ledger
func (*Service) InitialState ¶
func (s *Service) InitialState(ctx context.Context, req *emptypb.Empty) (*ledgerpb.StateResponse, error)
InitialState returns the initial state of the ledger
func (*Service) Prove ¶
func (s *Service) Prove(ctx context.Context, req *ledgerpb.ProveRequest) (*ledgerpb.ProofResponse, error)
Prove returns proofs for the given keys at a specific state
func (*Service) Set ¶
func (s *Service) Set(ctx context.Context, req *ledgerpb.SetRequest) (*ledgerpb.SetResponse, error)
Set updates keys with new values at a specific state and returns the new state