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(arg0 context.Context, arg1 *sync.SyncGetChangeProofRequest, arg2 DB) (*merkledb.ChangeProof, error)
- func (m *MockClient) GetRangeProof(arg0 context.Context, arg1 *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 ( ErrAcquiringSemaphore = errors.New("error acquiring semaphore") ErrRequestFailed = errors.New("request failed") )
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, returning a parsed StateResponse or error // Note: this verifies the response including the range proof. GetRangeProof(ctx context.Context, request *pb.SyncGetRangeProofRequest) (*merkledb.RangeProof, error) // GetChangeProof synchronously sends the given request, returning a parsed ChangesResponse or error // [verificationDB] is the local db that has all key/values in it for the proof's startroot within the proof's key range // Note: this verifies the response including the change proof. GetChangeProof(ctx context.Context, request *pb.SyncGetChangeProofRequest, verificationDB DB) (*merkledb.ChangeProof, 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
type ClientConfig ¶
type ClientConfig struct { NetworkClient NetworkClient StateSyncNodeIDs []ids.NodeID StateSyncMinVersion *version.Application Log logging.Logger Metrics SyncMetrics }
type DB ¶ added in v1.10.4
type DB interface { 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.ChangeProof, 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 interface{}) *gomock.Call
GetChangeProof indicates an expected call of GetChangeProof.
func (*MockClientMockRecorder) GetRangeProof ¶
func (mr *MockClientMockRecorder) GetRangeProof(arg0, arg1 interface{}) *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, minVersion *version.Application, request []byte) ([]byte, ids.NodeID, error) // Request synchronously sends request to the selected nodeID. // Returns response bytes, and ErrRequestFailed if the request should be retried. Request(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error) // TrackBandwidth should be called for each valid response with the bandwidth // (length of response divided by request time), and with 0 if the response is invalid. TrackBandwidth(nodeID ids.NodeID, bandwidth float64) // The following declarations allow this interface to be embedded in the VM // to handle incoming responses from peers. AppResponse(context.Context, ids.NodeID, uint32, []byte) error AppRequestFailed(context.Context, ids.NodeID, uint32) error Connected(context.Context, ids.NodeID, *version.Application) error Disconnected(context.Context, ids.NodeID) error }
NetworkClient defines ability to send request / response through the Network
func NewNetworkClient ¶
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. Never returns errors as they are considered fatal. 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].
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]. TODO danlaine how should we handle context cancellation?
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)