Documentation ¶
Overview ¶
Package sync is a generated GoMock package.
Index ¶
- Variables
- type Client
- type ClientConfig
- type DB
- type Manager
- type ManagerConfig
- type MockClient
- func (m *MockClient) EXPECT() *MockClientMockRecorder
- func (m *MockClient) GetChangeProof(ctx context.Context, request *sync.SyncGetChangeProofRequest, ...) (*merkledb.ChangeOrRangeProof, error)
- func (m *MockClient) GetRangeProof(ctx context.Context, request *sync.SyncGetRangeProofRequest) (*merkledb.RangeProof, error)
- type MockClientMockRecorder
- type NetworkClient
- type NetworkServer
- func (s *NetworkServer) AppRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, ...) error
- func (s *NetworkServer) HandleChangeProofRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, ...) error
- func (s *NetworkServer) HandleRangeProofRequest(ctx context.Context, nodeID ids.NodeID, requestID uint32, ...) error
- type ResponseHandler
- type SyncMetrics
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyStarted = errors.New("cannot start a Manager that has already been started") ErrAlreadyClosed = errors.New("Manager is closed") ErrNoClientProvided = errors.New("client is a required field of the sync config") ErrNoDatabaseProvided = errors.New("sync database is a required field of the sync config") ErrNoLogProvided = errors.New("log is a required field of the sync config") ErrZeroWorkLimit = errors.New("simultaneous work limit must be greater than 0") ErrFinishedWithUnexpectedRoot = errors.New("finished syncing with an unexpected root") )
var (
ErrMinProofSizeIsTooLarge = errors.New("cannot generate any proof within the requested limit")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // GetRangeProof synchronously sends the given request // and returns the parsed response. // This method verifies the range proof before returning it. GetRangeProof( ctx context.Context, request *pb.SyncGetRangeProofRequest, ) (*merkledb.RangeProof, error) // GetChangeProof synchronously sends the given request // and returns the parsed response. // This method verifies the change proof / range proof // before returning it. // If the server responds with a change proof, // it's verified using [verificationDB]. GetChangeProof( ctx context.Context, request *pb.SyncGetChangeProofRequest, verificationDB DB, ) (*merkledb.ChangeOrRangeProof, error) }
Client synchronously fetches data from the network to fulfill state sync requests. Repeatedly retries failed requests until the context is canceled.
func NewClient ¶
func NewClient(config *ClientConfig) (Client, error)
type ClientConfig ¶
type ClientConfig struct { NetworkClient NetworkClient StateSyncNodeIDs []ids.NodeID Log logging.Logger Metrics SyncMetrics BranchFactor merkledb.BranchFactor // If not specified, [merkledb.DefaultHasher] will be used. Hasher merkledb.Hasher }
type DB ¶
type DB interface { merkledb.Clearer merkledb.MerkleRootGetter merkledb.ProofGetter merkledb.ChangeProofer merkledb.RangeProofer }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(config ManagerConfig) (*Manager, error)
type ManagerConfig ¶
type MockClient ¶
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface.
func NewMockClient ¶
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (*MockClient) EXPECT ¶
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockClient) GetChangeProof ¶
func (m *MockClient) GetChangeProof(ctx context.Context, request *sync.SyncGetChangeProofRequest, verificationDB DB) (*merkledb.ChangeOrRangeProof, error)
GetChangeProof mocks base method.
func (*MockClient) GetRangeProof ¶
func (m *MockClient) GetRangeProof(ctx context.Context, request *sync.SyncGetRangeProofRequest) (*merkledb.RangeProof, error)
GetRangeProof mocks base method.
type MockClientMockRecorder ¶
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient.
func (*MockClientMockRecorder) GetChangeProof ¶
func (mr *MockClientMockRecorder) GetChangeProof(ctx, request, verificationDB any) *gomock.Call
GetChangeProof indicates an expected call of GetChangeProof.
func (*MockClientMockRecorder) GetRangeProof ¶
func (mr *MockClientMockRecorder) GetRangeProof(ctx, request any) *gomock.Call
GetRangeProof indicates an expected call of GetRangeProof.
type NetworkClient ¶
type NetworkClient interface { // RequestAny synchronously sends request to an arbitrary peer with a // node version greater than or equal to minVersion. // Returns response bytes, the ID of the chosen peer, and ErrRequestFailed if // the request should be retried. RequestAny( ctx context.Context, request []byte, ) (ids.NodeID, []byte, error) // Sends [request] to [nodeID] and returns the response. // Blocks until the number of outstanding requests is // below the limit before sending the request. Request( ctx context.Context, nodeID ids.NodeID, request []byte, ) ([]byte, error) // Always returns nil because the engine considers errors // returned from this function as fatal. AppResponse(context.Context, ids.NodeID, uint32, []byte) error // Always returns nil because the engine considers errors // returned from this function as fatal. AppRequestFailed(context.Context, ids.NodeID, uint32) error // Adds the given [nodeID] to the peer // list so that it can receive messages. // If [nodeID] is this node's ID, this is a no-op. Connected(context.Context, ids.NodeID, *version.Application) error // Removes given [nodeID] from the peer list. Disconnected(context.Context, ids.NodeID) error }
NetworkClient defines ability to send request / response through the Network
func NewNetworkClient ¶
func NewNetworkClient( appSender common.AppSender, myNodeID ids.NodeID, maxActiveRequests int64, log logging.Logger, metricsNamespace string, registerer prometheus.Registerer, minVersion *version.Application, ) (NetworkClient, error)
type NetworkServer ¶
type NetworkServer struct {
// contains filtered or unexported fields
}
func NewNetworkServer ¶
func (*NetworkServer) AppRequest ¶
func (s *NetworkServer) AppRequest( ctx context.Context, nodeID ids.NodeID, requestID uint32, deadline time.Time, request []byte, ) error
AppRequest is called by avalanchego -> VM when there is an incoming AppRequest from a peer. Returns a non-nil error iff we fail to send an app message. This is a fatal error. Sends a response back to the sender if length of response returned by the handler > 0.
func (*NetworkServer) HandleChangeProofRequest ¶
func (s *NetworkServer) HandleChangeProofRequest( ctx context.Context, nodeID ids.NodeID, requestID uint32, req *pb.SyncGetChangeProofRequest, ) error
Generates a change proof and sends it to [nodeID]. If [errAppSendFailed] is returned, this should be considered fatal.
func (*NetworkServer) HandleRangeProofRequest ¶
func (s *NetworkServer) HandleRangeProofRequest( ctx context.Context, nodeID ids.NodeID, requestID uint32, req *pb.SyncGetRangeProofRequest, ) error
Generates a range proof and sends it to [nodeID]. If [errAppSendFailed] is returned, this should be considered fatal.
type ResponseHandler ¶
type ResponseHandler interface { // Called when [response] is received. OnResponse(response []byte) // Called when the request failed or timed out. OnFailure() }
Handles responses/failure notifications for a sent request. Exactly one of OnResponse or OnFailure is eventually called.
type SyncMetrics ¶
type SyncMetrics interface { RequestFailed() RequestMade() RequestSucceeded() }
func NewMetrics ¶
func NewMetrics(namespace string, reg prometheus.Registerer) (SyncMetrics, error)