Documentation ¶
Overview ¶
Package sync is a generated GoMock package.
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(arg0 context.Context, arg1 *sync.SyncGetChangeProofRequest, arg2 DB) (*merkledb.ChangeOrRangeProof, error)
- func (m *MockClient) GetRangeProof(arg0 context.Context, arg1 *sync.SyncGetRangeProofRequest) (*merkledb.RangeProof, error)
- type MockClientMockRecorder
- type MockNetworkClient
- func (m *MockNetworkClient) AppRequestFailed(arg0 context.Context, arg1 ids.NodeID, arg2 uint32) error
- func (m *MockNetworkClient) AppResponse(arg0 context.Context, arg1 ids.NodeID, arg2 uint32, arg3 []byte) error
- func (m *MockNetworkClient) Connected(arg0 context.Context, arg1 ids.NodeID, arg2 *version.Application) error
- func (m *MockNetworkClient) Disconnected(arg0 context.Context, arg1 ids.NodeID) error
- func (m *MockNetworkClient) EXPECT() *MockNetworkClientMockRecorder
- func (m *MockNetworkClient) Request(arg0 context.Context, arg1 ids.NodeID, arg2 []byte) ([]byte, error)
- func (m *MockNetworkClient) RequestAny(arg0 context.Context, arg1 []byte) (ids.NodeID, []byte, error)
- type MockNetworkClientMockRecorder
- func (mr *MockNetworkClientMockRecorder) AppRequestFailed(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockNetworkClientMockRecorder) AppResponse(arg0, arg1, arg2, arg3 any) *gomock.Call
- func (mr *MockNetworkClientMockRecorder) Connected(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockNetworkClientMockRecorder) Disconnected(arg0, arg1 any) *gomock.Call
- func (mr *MockNetworkClientMockRecorder) Request(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockNetworkClientMockRecorder) RequestAny(arg0, arg1 any) *gomock.Call
- 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 ¶ added in v1.10.4
type DB interface { merkledb.Clearer merkledb.MerkleRootGetter merkledb.ProofGetter merkledb.ChangeProofer merkledb.RangeProofer }
type Manager ¶ added in v1.10.4
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶ added in v1.10.4
func NewManager(config ManagerConfig) (*Manager, error)
func (*Manager) Close ¶ added in v1.10.4
func (m *Manager) Close()
Close will stop the syncing process
func (*Manager) UpdateSyncTarget ¶ added in v1.10.4
type ManagerConfig ¶ added in v1.10.4
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(arg0 context.Context, arg1 *sync.SyncGetChangeProofRequest, arg2 DB) (*merkledb.ChangeOrRangeProof, error)
GetChangeProof mocks base method.
func (*MockClient) GetRangeProof ¶
func (m *MockClient) GetRangeProof(arg0 context.Context, arg1 *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(arg0, arg1, arg2 any) *gomock.Call
GetChangeProof indicates an expected call of GetChangeProof.
func (*MockClientMockRecorder) GetRangeProof ¶
func (mr *MockClientMockRecorder) GetRangeProof(arg0, arg1 any) *gomock.Call
GetRangeProof indicates an expected call of GetRangeProof.
type MockNetworkClient ¶ added in v1.10.8
type MockNetworkClient struct {
// contains filtered or unexported fields
}
MockNetworkClient is a mock of NetworkClient interface.
func NewMockNetworkClient ¶ added in v1.10.8
func NewMockNetworkClient(ctrl *gomock.Controller) *MockNetworkClient
NewMockNetworkClient creates a new mock instance.
func (*MockNetworkClient) AppRequestFailed ¶ added in v1.10.8
func (m *MockNetworkClient) AppRequestFailed(arg0 context.Context, arg1 ids.NodeID, arg2 uint32) error
AppRequestFailed mocks base method.
func (*MockNetworkClient) AppResponse ¶ added in v1.10.8
func (m *MockNetworkClient) AppResponse(arg0 context.Context, arg1 ids.NodeID, arg2 uint32, arg3 []byte) error
AppResponse mocks base method.
func (*MockNetworkClient) Connected ¶ added in v1.10.8
func (m *MockNetworkClient) Connected(arg0 context.Context, arg1 ids.NodeID, arg2 *version.Application) error
Connected mocks base method.
func (*MockNetworkClient) Disconnected ¶ added in v1.10.8
Disconnected mocks base method.
func (*MockNetworkClient) EXPECT ¶ added in v1.10.8
func (m *MockNetworkClient) EXPECT() *MockNetworkClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockNetworkClient) Request ¶ added in v1.10.8
func (m *MockNetworkClient) Request(arg0 context.Context, arg1 ids.NodeID, arg2 []byte) ([]byte, error)
Request mocks base method.
func (*MockNetworkClient) RequestAny ¶ added in v1.10.8
func (m *MockNetworkClient) RequestAny(arg0 context.Context, arg1 []byte) (ids.NodeID, []byte, error)
RequestAny mocks base method.
type MockNetworkClientMockRecorder ¶ added in v1.10.8
type MockNetworkClientMockRecorder struct {
// contains filtered or unexported fields
}
MockNetworkClientMockRecorder is the mock recorder for MockNetworkClient.
func (*MockNetworkClientMockRecorder) AppRequestFailed ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) AppRequestFailed(arg0, arg1, arg2 any) *gomock.Call
AppRequestFailed indicates an expected call of AppRequestFailed.
func (*MockNetworkClientMockRecorder) AppResponse ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) AppResponse(arg0, arg1, arg2, arg3 any) *gomock.Call
AppResponse indicates an expected call of AppResponse.
func (*MockNetworkClientMockRecorder) Connected ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) Connected(arg0, arg1, arg2 any) *gomock.Call
Connected indicates an expected call of Connected.
func (*MockNetworkClientMockRecorder) Disconnected ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) Disconnected(arg0, arg1 any) *gomock.Call
Disconnected indicates an expected call of Disconnected.
func (*MockNetworkClientMockRecorder) Request ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) Request(arg0, arg1, arg2 any) *gomock.Call
Request indicates an expected call of Request.
func (*MockNetworkClientMockRecorder) RequestAny ¶ added in v1.10.8
func (mr *MockNetworkClientMockRecorder) RequestAny(arg0, arg1 any) *gomock.Call
RequestAny indicates an expected call of RequestAny.
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)