remote

package
v0.46.2-util-print-chu... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

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

func NewClient(grpcAddr string, logger zerolog.Logger, opts ...ClientOption) (*Client, error)

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) Close

func (c *Client) Close() error

Close closes the gRPC connection.

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) Get

func (c *Client) Get(query *ledger.Query) ([]ledger.Value, error)

Get returns values for multiple keys at a specific state.

func (*Client) GetSingleValue

func (c *Client) GetSingleValue(query *ledger.QuerySingleValue) (ledger.Value, error)

GetSingleValue returns a single value for a given key at a specific state.

func (*Client) HasState

func (c *Client) HasState(state ledger.State) bool

HasState returns true if the given state exists in the ledger.

func (*Client) InitialState

func (c *Client) InitialState() ledger.State

InitialState returns the initial state of the ledger.

func (*Client) Prove

func (c *Client) Prove(query *ledger.Query) (ledger.Proof, error)

Prove returns proofs for the given keys at a specific state.

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

func (c *Client) Set(update *ledger.Update) (ledger.State, *ledger.TrieUpdate, error)

Set updates keys with new values at a specific state and returns the new state.

func (*Client) StateByIndex

func (c *Client) StateByIndex(index int) (ledger.State, error)

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

func (c *Client) StateCount() int

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.

func (*RemoteLedgerFactory) NewLedger

func (f *RemoteLedgerFactory) NewLedger() (ledger.Ledger, error)

type Service

type Service struct {
	ledgerpb.UnimplementedLedgerServiceServer
	// contains filtered or unexported fields
}

Service implements the gRPC LedgerService interface

func NewService

func NewService(l ledger.Ledger, logger zerolog.Logger) *Service

NewService creates a new ledger service

func (*Service) Get

Get returns values for multiple keys at a specific state

func (*Service) GetSingleValue

GetSingleValue returns a single value for a given key at a specific state

func (*Service) HasState

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

Prove returns proofs for the given keys at a specific state

func (*Service) Set

Set updates keys with new values at a specific state and returns the new state

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL