Documentation
¶
Overview ¶
Package sync is a generated GoMock package.
Package sync is a generated GoMock package.
Index ¶
- Variables
- type ByteWorkHeap
- type ChangeOrRangeProof
- type Client
- type ClientConfig
- type DB
- type GenericWorkHeap
- type GenericWorkItem
- type GetChangeProofHandler
- type GetRangeProofHandler
- type Manager
- type ManagerConfig
- type MockClient
- func (m *MockClient) EXPECT() *MockClientMockRecorder
- func (m *MockClient) GetChangeProof(arg0 context.Context, arg1 *sync.SyncGetChangeProofRequest, arg2 DB) (*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 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") ErrNoRangeProofClientProvided = errors.New("range proof client is a required field of the sync config") ErrNoChangeProofClientProvided = errors.New("change proof 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 ByteWorkHeap ¶ added in v1.16.56
type ByteWorkHeap struct {
*GenericWorkHeap[[]byte]
}
ByteWorkHeap is a specialized work heap for byte slices This provides backward compatibility with the existing implementation
func NewByteWorkHeap ¶ added in v1.16.56
func NewByteWorkHeap() *ByteWorkHeap
NewByteWorkHeap creates a new byte-based work heap
type ChangeOrRangeProof ¶ added in v1.16.56
type ChangeOrRangeProof struct {
ChangeProof *merkledb.ChangeProof
RangeProof *merkledb.RangeProof
}
ChangeOrRangeProof contains either a ChangeProof or RangeProof. Exactly one of ChangeProof or RangeProof should be non-nil.
type Client ¶ added in v1.1.11
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,
) (*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 ¶ added in v1.1.11
func NewClient(config *ClientConfig) (Client, error)
type ClientConfig ¶ added in v1.1.11
type ClientConfig struct {
NetworkClient NetworkClient
StateSyncNodeIDs []ids.NodeID
Log log.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 GenericWorkHeap ¶ added in v1.16.56
type GenericWorkHeap[T any] struct { // contains filtered or unexported fields }
GenericWorkHeap is a priority queue that can work with any type T
func NewGenericWorkHeap ¶ added in v1.16.56
func NewGenericWorkHeap[T any](compareFn func(a, b T) int, equalFn func(a, b T) bool) *GenericWorkHeap[T]
NewGenericWorkHeap creates a new generic work heap
func (*GenericWorkHeap[T]) Close ¶ added in v1.16.56
func (wh *GenericWorkHeap[T]) Close()
Close marks the heap as closed
func (*GenericWorkHeap[T]) GetWork ¶ added in v1.16.56
func (wh *GenericWorkHeap[T]) GetWork() *GenericWorkItem[T]
GetWork pops and returns a work item from the heap
func (*GenericWorkHeap[T]) Insert ¶ added in v1.16.56
func (wh *GenericWorkHeap[T]) Insert(item *GenericWorkItem[T])
Insert adds a new item into the heap
func (*GenericWorkHeap[T]) Len ¶ added in v1.16.56
func (wh *GenericWorkHeap[T]) Len() int
Len returns the number of items in the heap
func (*GenericWorkHeap[T]) MergeInsert ¶ added in v1.16.56
func (wh *GenericWorkHeap[T]) MergeInsert(item *GenericWorkItem[T])
MergeInsert inserts the item into the heap, merging with adjacent items if possible
type GenericWorkItem ¶ added in v1.16.56
type GenericWorkItem[T any] struct { Start maybe.Maybe[T] End maybe.Maybe[T] Priority priority LocalRootID ids.ID Attempt int QueueTime time.Time }
GenericWorkItem represents a work item that can work with any comparable type T
func NewGenericWorkItem ¶ added in v1.16.56
func NewGenericWorkItem[T any]( localRootID ids.ID, start maybe.Maybe[T], end maybe.Maybe[T], priority priority, queueTime time.Time, ) *GenericWorkItem[T]
NewGenericWorkItem creates a new generic work item
func (*GenericWorkItem[T]) RequestFailed ¶ added in v1.16.56
func (w *GenericWorkItem[T]) RequestFailed()
RequestFailed increments the attempt counter
type GetChangeProofHandler ¶
type GetChangeProofHandler struct {
// contains filtered or unexported fields
}
func NewGetChangeProofHandler ¶
func NewGetChangeProofHandler(db DB) *GetChangeProofHandler
type GetRangeProofHandler ¶
type GetRangeProofHandler struct {
// contains filtered or unexported fields
}
func NewGetRangeProofHandler ¶
func NewGetRangeProofHandler(db DB) *GetRangeProofHandler
type Manager ¶
type Manager[T any] struct { // contains filtered or unexported fields }
func NewManager ¶
func NewManager[T any](config ManagerConfig[T], registerer prometheus.Registerer) (*Manager[T], error)
func (*Manager[T]) UpdateSyncTarget ¶
type ManagerConfig ¶
type ManagerConfig[T any] struct { DB DB RangeProofClient *p2p.Client ChangeProofClient *p2p.Client SimultaneousWorkLimit int Log log.Logger TargetRoot ids.ID BranchFactor merkledb.BranchFactor StateSyncNodes []ids.NodeID // If not specified, [merkledb.DefaultHasher] will be used. Hasher merkledb.Hasher }
TODO remove non-config values out of this struct
type MockClient ¶ added in v1.1.11
type MockClient struct {
// contains filtered or unexported fields
}
MockClient is a mock of Client interface.
func NewMockClient ¶ added in v1.1.11
func NewMockClient(ctrl *gomock.Controller) *MockClient
NewMockClient creates a new mock instance.
func (*MockClient) EXPECT ¶ added in v1.1.11
func (m *MockClient) EXPECT() *MockClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockClient) GetChangeProof ¶ added in v1.1.11
func (m *MockClient) GetChangeProof(arg0 context.Context, arg1 *sync.SyncGetChangeProofRequest, arg2 DB) (*ChangeOrRangeProof, error)
GetChangeProof mocks base method.
func (*MockClient) GetRangeProof ¶ added in v1.1.11
func (m *MockClient) GetRangeProof(arg0 context.Context, arg1 *sync.SyncGetRangeProofRequest) (*merkledb.RangeProof, error)
GetRangeProof mocks base method.
type MockClientMockRecorder ¶ added in v1.1.11
type MockClientMockRecorder struct {
// contains filtered or unexported fields
}
MockClientMockRecorder is the mock recorder for MockClient.
func (*MockClientMockRecorder) GetChangeProof ¶ added in v1.1.11
func (mr *MockClientMockRecorder) GetChangeProof(arg0, arg1, arg2 any) *gomock.Call
GetChangeProof indicates an expected call of GetChangeProof.
func (*MockClientMockRecorder) GetRangeProof ¶ added in v1.1.11
func (mr *MockClientMockRecorder) GetRangeProof(arg0, arg1 any) *gomock.Call
GetRangeProof indicates an expected call of GetRangeProof.
type MockNetworkClient ¶ added in v1.1.11
type MockNetworkClient struct {
// contains filtered or unexported fields
}
MockNetworkClient is a mock of NetworkClient interface.
func NewMockNetworkClient ¶ added in v1.1.11
func NewMockNetworkClient(ctrl *gomock.Controller) *MockNetworkClient
NewMockNetworkClient creates a new mock instance.
func (*MockNetworkClient) AppRequestFailed ¶ added in v1.1.11
func (m *MockNetworkClient) AppRequestFailed(arg0 context.Context, arg1 ids.NodeID, arg2 uint32) error
AppRequestFailed mocks base method.
func (*MockNetworkClient) AppResponse ¶ added in v1.1.11
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.1.11
func (m *MockNetworkClient) Connected(arg0 context.Context, arg1 ids.NodeID, arg2 *version.Application) error
Connected mocks base method.
func (*MockNetworkClient) Disconnected ¶ added in v1.1.11
Disconnected mocks base method.
func (*MockNetworkClient) EXPECT ¶ added in v1.1.11
func (m *MockNetworkClient) EXPECT() *MockNetworkClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockNetworkClient) Request ¶ added in v1.1.11
func (m *MockNetworkClient) Request(arg0 context.Context, arg1 ids.NodeID, arg2 []byte) ([]byte, error)
Request mocks base method.
func (*MockNetworkClient) RequestAny ¶ added in v1.1.11
func (m *MockNetworkClient) RequestAny(arg0 context.Context, arg1 []byte) (ids.NodeID, []byte, error)
RequestAny mocks base method.
type MockNetworkClientMockRecorder ¶ added in v1.1.11
type MockNetworkClientMockRecorder struct {
// contains filtered or unexported fields
}
MockNetworkClientMockRecorder is the mock recorder for MockNetworkClient.
func (*MockNetworkClientMockRecorder) AppRequestFailed ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) AppRequestFailed(arg0, arg1, arg2 any) *gomock.Call
AppRequestFailed indicates an expected call of AppRequestFailed.
func (*MockNetworkClientMockRecorder) AppResponse ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) AppResponse(arg0, arg1, arg2, arg3 any) *gomock.Call
AppResponse indicates an expected call of AppResponse.
func (*MockNetworkClientMockRecorder) Connected ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) Connected(arg0, arg1, arg2 any) *gomock.Call
Connected indicates an expected call of Connected.
func (*MockNetworkClientMockRecorder) Disconnected ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) Disconnected(arg0, arg1 any) *gomock.Call
Disconnected indicates an expected call of Disconnected.
func (*MockNetworkClientMockRecorder) Request ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) Request(arg0, arg1, arg2 any) *gomock.Call
Request indicates an expected call of Request.
func (*MockNetworkClientMockRecorder) RequestAny ¶ added in v1.1.11
func (mr *MockNetworkClientMockRecorder) RequestAny(arg0, arg1 any) *gomock.Call
RequestAny indicates an expected call of RequestAny.
type NetworkClient ¶ added in v1.1.11
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, *consensusversion.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 ¶ added in v1.1.11
func NewNetworkClient( sender warp.Sender, myNodeID ids.NodeID, maxActiveRequests int64, log log.Logger, metricsNamespace string, registerer metric.Registerer, minVersion *consensusversion.Application, ) (NetworkClient, error)
type ResponseHandler ¶ added in v1.1.11
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 metric.Registerer) (SyncMetrics, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package syncmock is a generated GoMock package.
|
Package syncmock is a generated GoMock package. |