statesyncclient

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: GPL-3.0, LGPL-3.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StateSyncVersion = &version.Application{
		Major: 1,
		Minor: 7,
		Patch: 13,
	}
)

Functions

func NewClient

func NewClient(config *ClientConfig) *client

Types

type Client

type Client interface {
	// GetLeafs synchronously sends the given request, returning a parsed LeafsResponse or error
	// Note: this verifies the response including the range proofs.
	GetLeafs(ctx context.Context, request message.LeafsRequest) (message.LeafsResponse, error)

	// GetBlocks synchronously retrieves blocks starting with specified common.Hash and height up to specified parents
	// specified range from height to height-parents is inclusive
	GetBlocks(ctx context.Context, blockHash common.Hash, height uint64, parents uint16) ([]*types.Block, error)

	// GetCode synchronously retrieves code associated with the given hashes
	GetCode(ctx context.Context, hashes []common.Hash) ([][]byte, error)
}

Client synchronously fetches data from the network to fulfill state sync requests. Repeatedly requests failed requests until the context to the request is expired.

type ClientConfig

type ClientConfig struct {
	NetworkClient    network.SyncedNetworkClient
	Codec            codec.Manager
	Stats            stats.ClientSyncerStats
	StateSyncNodeIDs []ids.NodeID
	BlockParser      EthBlockParser
}

type EthBlockParser

type EthBlockParser interface {
	ParseEthBlock(b []byte) (*types.Block, error)
}

type TestClient added in v0.8.1

type TestClient struct {

	// GetLeafsIntercept is called on every GetLeafs request if set to a non-nil callback.
	// The returned response will be returned by TestClient to the caller.
	GetLeafsIntercept func(req message.LeafsRequest, res message.LeafsResponse) (message.LeafsResponse, error)
	// GetCodesIntercept is called on every GetCode request if set to a non-nil callback.
	// The returned response will be returned by TestClient to the caller.
	GetCodeIntercept func(hashes []common.Hash, codeBytes [][]byte) ([][]byte, error)
	// GetBlocksIntercept is called on every GetBlocks request if set to a non-nil callback.
	// The returned response will be returned by TestClient to the caller.
	GetBlocksIntercept func(blockReq message.BlockRequest, blocks types.Blocks) (types.Blocks, error)
	// contains filtered or unexported fields
}

func NewTestClient added in v0.8.1

func NewTestClient(
	codec codec.Manager,
	leafHandler handlers.LeafRequestHandler,
	codesHandler *handlers.CodeRequestHandler,
	blocksHandler *handlers.BlockRequestHandler,
) *TestClient

func (*TestClient) BlocksReceived added in v0.8.1

func (ml *TestClient) BlocksReceived() int32

func (*TestClient) CodeReceived added in v0.8.1

func (ml *TestClient) CodeReceived() int32

func (*TestClient) GetBlocks added in v0.8.1

func (ml *TestClient) GetBlocks(ctx context.Context, blockHash common.Hash, height uint64, numParents uint16) ([]*types.Block, error)

func (*TestClient) GetCode added in v0.8.1

func (ml *TestClient) GetCode(ctx context.Context, hashes []common.Hash) ([][]byte, error)

func (*TestClient) GetLeafs added in v0.8.1

func (ml *TestClient) GetLeafs(ctx context.Context, request message.LeafsRequest) (message.LeafsResponse, error)

func (*TestClient) LeavesReceived added in v0.8.1

func (ml *TestClient) LeavesReceived() int32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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