p2p

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package p2p is a generated GoMock package.

Package p2p is a generated GoMock package.

Package p2p is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFetchBlocksAmount = errors.New("invalid fetch blocks amount")
View Source
var ErrPeerNotFound = errors.New("peer not found")

Functions

func PreservingPeerShuffle

func PreservingPeerShuffle(_ []*PeerId)

func RandPeerShuffle

func RandPeerShuffle(peerIds []*PeerId)

func WithPreservingPeerShuffle

func WithPreservingPeerShuffle(pt *peerTracker)

Types

type DecodedInboundMessage

type DecodedInboundMessage[TPacket any] struct {
	*sentryproto.InboundMessage
	Decoded TPacket
	PeerId  *PeerId
}

type ErrIncompleteHeaders

type ErrIncompleteHeaders struct {
	// contains filtered or unexported fields
}

func (ErrIncompleteHeaders) Error

func (e ErrIncompleteHeaders) Error() string

func (ErrIncompleteHeaders) Is

func (e ErrIncompleteHeaders) Is(err error) bool

func (ErrIncompleteHeaders) LowestMissingBlockNum

func (e ErrIncompleteHeaders) LowestMissingBlockNum() uint64

type ErrInvalidFetchHeadersRange

type ErrInvalidFetchHeadersRange struct {
	// contains filtered or unexported fields
}

func (ErrInvalidFetchHeadersRange) Error

func (ErrInvalidFetchHeadersRange) Is

type ErrMissingBodies

type ErrMissingBodies struct {
	// contains filtered or unexported fields
}

func NewErrMissingBodies

func NewErrMissingBodies(headers []*types.Header) *ErrMissingBodies

func (ErrMissingBodies) Error

func (e ErrMissingBodies) Error() string

func (ErrMissingBodies) Is

func (e ErrMissingBodies) Is(err error) bool

func (ErrMissingBodies) LowestMissingBlockNum

func (e ErrMissingBodies) LowestMissingBlockNum() (uint64, bool)

type ErrMissingHeaderHash

type ErrMissingHeaderHash struct {
	// contains filtered or unexported fields
}

func (ErrMissingHeaderHash) Error

func (e ErrMissingHeaderHash) Error() string

func (ErrMissingHeaderHash) Is

func (e ErrMissingHeaderHash) Is(err error) bool

type ErrNonSequentialHeaderHashes

type ErrNonSequentialHeaderHashes struct {
	// contains filtered or unexported fields
}

func (ErrNonSequentialHeaderHashes) Error

func (ErrNonSequentialHeaderHashes) Is

type ErrNonSequentialHeaderNumbers

type ErrNonSequentialHeaderNumbers struct {
	// contains filtered or unexported fields
}

func (ErrNonSequentialHeaderNumbers) Error

func (ErrNonSequentialHeaderNumbers) Is

type ErrTooManyBodies

type ErrTooManyBodies struct {
	// contains filtered or unexported fields
}

func (ErrTooManyBodies) Error

func (e ErrTooManyBodies) Error() string

func (ErrTooManyBodies) Is

func (e ErrTooManyBodies) Is(err error) bool

type ErrTooManyHeaders

type ErrTooManyHeaders struct {
	// contains filtered or unexported fields
}

func (ErrTooManyHeaders) Error

func (e ErrTooManyHeaders) Error() string

func (ErrTooManyHeaders) Is

func (e ErrTooManyHeaders) Is(err error) bool

type ErrUnexpectedHeaderHash

type ErrUnexpectedHeaderHash struct {
	// contains filtered or unexported fields
}

func (ErrUnexpectedHeaderHash) Error

func (e ErrUnexpectedHeaderHash) Error() string

func (ErrUnexpectedHeaderHash) Is

type Fetcher

type Fetcher interface {
	// FetchHeaders fetches [start,end) headers from a peer. Blocks until data is received.
	FetchHeaders(
		ctx context.Context,
		start uint64,
		end uint64,
		peerId *PeerId,
		opts ...FetcherOption,
	) (FetcherResponse[[]*types.Header], error)

	// FetchBodies fetches block bodies for the given headers from a peer. Blocks until data is received.
	FetchBodies(
		ctx context.Context,
		headers []*types.Header,
		peerId *PeerId,
		opts ...FetcherOption,
	) (FetcherResponse[[]*types.Body], error)

	// FetchBlocksBackwardsByHash fetches a number of blocks backwards starting from a block hash. Max amount is 1024
	// blocks back. Blocks until data is received.
	FetchBlocksBackwardsByHash(
		ctx context.Context,
		hash common.Hash,
		amount uint64,
		peerId *PeerId,
		opts ...FetcherOption,
	) (FetcherResponse[[]*types.Block], error)
}

func NewFetcher

func NewFetcher(
	logger log.Logger,
	config FetcherConfig,
	messageListener MessageListener,
	messageSender MessageSender,
	requestIdGenerator RequestIdGenerator,
) Fetcher

func NewPenalizingFetcher

func NewPenalizingFetcher(logger log.Logger, fetcher Fetcher, peerPenalizer PeerPenalizer) Fetcher

func NewTrackingFetcher

func NewTrackingFetcher(fetcher Fetcher, peerTracker PeerTracker) Fetcher

type FetcherConfig

type FetcherConfig struct {
	// contains filtered or unexported fields
}

func (FetcherConfig) CopyWithOptions

func (fc FetcherConfig) CopyWithOptions(opts ...FetcherOption) FetcherConfig

type FetcherOption

type FetcherOption func(FetcherConfig) FetcherConfig

func WithMaxRetries

func WithMaxRetries(maxRetries uint64) FetcherOption

func WithResponseTimeout

func WithResponseTimeout(responseTimeout time.Duration) FetcherOption

type FetcherResponse

type FetcherResponse[T any] struct {
	Data      T
	TotalSize int
}

type MessageListener

type MessageListener interface {
	Run(ctx context.Context) error
	RegisterNewBlockObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.NewBlockPacket]]) UnregisterFunc
	RegisterNewBlockHashesObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.NewBlockHashesPacket]]) UnregisterFunc
	RegisterBlockHeadersObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.BlockHeadersPacket66]]) UnregisterFunc
	RegisterBlockBodiesObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.BlockBodiesPacket66]]) UnregisterFunc
	RegisterPeerEventObserver(observer polygoncommon.Observer[*sentryproto.PeerEvent]) UnregisterFunc
}

func NewMessageListener

func NewMessageListener(
	logger log.Logger,
	sentryClient sentryproto.SentryClient,
	statusDataFactory sentry.StatusDataFactory,
	peerPenalizer PeerPenalizer,
) MessageListener

type MessageSender

type MessageSender interface {
	SendGetBlockHeaders(ctx context.Context, peerId *PeerId, req eth.GetBlockHeadersPacket66) error
	SendGetBlockBodies(ctx context.Context, peerId *PeerId, req eth.GetBlockBodiesPacket66) error
	SendNewBlockHashes(ctx context.Context, peerId *PeerId, req eth.NewBlockHashesPacket) error
	SendNewBlock(ctx context.Context, peerId *PeerId, req eth.NewBlockPacket) error
}

func NewMessageSender

func NewMessageSender(sentryClient sentry.SentryClient) MessageSender

type MockService

type MockService struct {
	// contains filtered or unexported fields
}

MockService is a mock of Service interface.

func NewMockService

func NewMockService(ctrl *gomock.Controller) *MockService

NewMockService creates a new mock instance.

func (*MockService) BlockHashPresent

func (m *MockService) BlockHashPresent(peerId *PeerId, blockHash common.Hash)

BlockHashPresent mocks base method.

func (*MockService) BlockNumMissing

func (m *MockService) BlockNumMissing(peerId *PeerId, blockNum uint64)

BlockNumMissing mocks base method.

func (*MockService) BlockNumPresent

func (m *MockService) BlockNumPresent(peerId *PeerId, blockNum uint64)

BlockNumPresent mocks base method.

func (*MockService) EXPECT

func (m *MockService) EXPECT() *MockServiceMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockService) FetchBlocksBackwardsByHash

func (m *MockService) FetchBlocksBackwardsByHash(ctx context.Context, hash common.Hash, amount uint64, peerId *PeerId, opts ...FetcherOption) (FetcherResponse[[]*types.Block], error)

FetchBlocksBackwardsByHash mocks base method.

func (*MockService) FetchBodies

func (m *MockService) FetchBodies(ctx context.Context, headers []*types.Header, peerId *PeerId, opts ...FetcherOption) (FetcherResponse[[]*types.Body], error)

FetchBodies mocks base method.

func (*MockService) FetchHeaders

func (m *MockService) FetchHeaders(ctx context.Context, start, end uint64, peerId *PeerId, opts ...FetcherOption) (FetcherResponse[[]*types.Header], error)

FetchHeaders mocks base method.

func (*MockService) ListPeersMayHaveBlockNum

func (m *MockService) ListPeersMayHaveBlockNum(blockNum uint64) []*PeerId

ListPeersMayHaveBlockNum mocks base method.

func (*MockService) ListPeersMayMissBlockHash

func (m *MockService) ListPeersMayMissBlockHash(blockHash common.Hash) []*PeerId

ListPeersMayMissBlockHash mocks base method.

func (*MockService) MaxPeers

func (m *MockService) MaxPeers() int

MaxPeers mocks base method.

func (*MockService) PeerConnected

func (m *MockService) PeerConnected(peerId *PeerId)

PeerConnected mocks base method.

func (*MockService) PeerDisconnected

func (m *MockService) PeerDisconnected(peerId *PeerId)

PeerDisconnected mocks base method.

func (*MockService) Penalize

func (m *MockService) Penalize(ctx context.Context, peerId *PeerId) error

Penalize mocks base method.

func (*MockService) PublishNewBlock

func (m *MockService) PublishNewBlock(block *types.Block, td *big.Int)

PublishNewBlock mocks base method.

func (*MockService) PublishNewBlockHashes

func (m *MockService) PublishNewBlockHashes(block *types.Block)

PublishNewBlockHashes mocks base method.

func (*MockService) RegisterBlockBodiesObserver

func (m *MockService) RegisterBlockBodiesObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.BlockBodiesPacket66]]) UnregisterFunc

RegisterBlockBodiesObserver mocks base method.

func (*MockService) RegisterBlockHeadersObserver

func (m *MockService) RegisterBlockHeadersObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.BlockHeadersPacket66]]) UnregisterFunc

RegisterBlockHeadersObserver mocks base method.

func (*MockService) RegisterNewBlockHashesObserver

func (m *MockService) RegisterNewBlockHashesObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.NewBlockHashesPacket]]) UnregisterFunc

RegisterNewBlockHashesObserver mocks base method.

func (*MockService) RegisterNewBlockObserver

func (m *MockService) RegisterNewBlockObserver(observer polygoncommon.Observer[*DecodedInboundMessage[*eth.NewBlockPacket]]) UnregisterFunc

RegisterNewBlockObserver mocks base method.

func (*MockService) RegisterPeerEventObserver

func (m *MockService) RegisterPeerEventObserver(observer polygoncommon.Observer[*sentryproto.PeerEvent]) UnregisterFunc

RegisterPeerEventObserver mocks base method.

func (*MockService) Run

func (m *MockService) Run(ctx context.Context) error

Run mocks base method.

type MockServiceBlockHashPresentCall

type MockServiceBlockHashPresentCall struct {
	*gomock.Call
}

MockServiceBlockHashPresentCall wrap *gomock.Call

func (*MockServiceBlockHashPresentCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceBlockHashPresentCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceBlockHashPresentCall) Return

Return rewrite *gomock.Call.Return

type MockServiceBlockNumMissingCall

type MockServiceBlockNumMissingCall struct {
	*gomock.Call
}

MockServiceBlockNumMissingCall wrap *gomock.Call

func (*MockServiceBlockNumMissingCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceBlockNumMissingCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceBlockNumMissingCall) Return

Return rewrite *gomock.Call.Return

type MockServiceBlockNumPresentCall

type MockServiceBlockNumPresentCall struct {
	*gomock.Call
}

MockServiceBlockNumPresentCall wrap *gomock.Call

func (*MockServiceBlockNumPresentCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceBlockNumPresentCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceBlockNumPresentCall) Return

Return rewrite *gomock.Call.Return

type MockServiceFetchBlocksBackwardsByHashCall

type MockServiceFetchBlocksBackwardsByHashCall struct {
	*gomock.Call
}

MockServiceFetchBlocksBackwardsByHashCall wrap *gomock.Call

func (*MockServiceFetchBlocksBackwardsByHashCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceFetchBlocksBackwardsByHashCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceFetchBlocksBackwardsByHashCall) Return

Return rewrite *gomock.Call.Return

type MockServiceFetchBodiesCall

type MockServiceFetchBodiesCall struct {
	*gomock.Call
}

MockServiceFetchBodiesCall wrap *gomock.Call

func (*MockServiceFetchBodiesCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceFetchBodiesCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceFetchBodiesCall) Return

Return rewrite *gomock.Call.Return

type MockServiceFetchHeadersCall

type MockServiceFetchHeadersCall struct {
	*gomock.Call
}

MockServiceFetchHeadersCall wrap *gomock.Call

func (*MockServiceFetchHeadersCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceFetchHeadersCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceFetchHeadersCall) Return

Return rewrite *gomock.Call.Return

type MockServiceListPeersMayHaveBlockNumCall

type MockServiceListPeersMayHaveBlockNumCall struct {
	*gomock.Call
}

MockServiceListPeersMayHaveBlockNumCall wrap *gomock.Call

func (*MockServiceListPeersMayHaveBlockNumCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceListPeersMayHaveBlockNumCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceListPeersMayHaveBlockNumCall) Return

Return rewrite *gomock.Call.Return

type MockServiceListPeersMayMissBlockHashCall

type MockServiceListPeersMayMissBlockHashCall struct {
	*gomock.Call
}

MockServiceListPeersMayMissBlockHashCall wrap *gomock.Call

func (*MockServiceListPeersMayMissBlockHashCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceListPeersMayMissBlockHashCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceListPeersMayMissBlockHashCall) Return

Return rewrite *gomock.Call.Return

type MockServiceMaxPeersCall

type MockServiceMaxPeersCall struct {
	*gomock.Call
}

MockServiceMaxPeersCall wrap *gomock.Call

func (*MockServiceMaxPeersCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceMaxPeersCall) DoAndReturn

func (c *MockServiceMaxPeersCall) DoAndReturn(f func() int) *MockServiceMaxPeersCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceMaxPeersCall) Return

Return rewrite *gomock.Call.Return

type MockServiceMockRecorder

type MockServiceMockRecorder struct {
	// contains filtered or unexported fields
}

MockServiceMockRecorder is the mock recorder for MockService.

func (*MockServiceMockRecorder) BlockHashPresent

func (mr *MockServiceMockRecorder) BlockHashPresent(peerId, blockHash any) *MockServiceBlockHashPresentCall

BlockHashPresent indicates an expected call of BlockHashPresent.

func (*MockServiceMockRecorder) BlockNumMissing

func (mr *MockServiceMockRecorder) BlockNumMissing(peerId, blockNum any) *MockServiceBlockNumMissingCall

BlockNumMissing indicates an expected call of BlockNumMissing.

func (*MockServiceMockRecorder) BlockNumPresent

func (mr *MockServiceMockRecorder) BlockNumPresent(peerId, blockNum any) *MockServiceBlockNumPresentCall

BlockNumPresent indicates an expected call of BlockNumPresent.

func (*MockServiceMockRecorder) FetchBlocksBackwardsByHash

func (mr *MockServiceMockRecorder) FetchBlocksBackwardsByHash(ctx, hash, amount, peerId any, opts ...any) *MockServiceFetchBlocksBackwardsByHashCall

FetchBlocksBackwardsByHash indicates an expected call of FetchBlocksBackwardsByHash.

func (*MockServiceMockRecorder) FetchBodies

func (mr *MockServiceMockRecorder) FetchBodies(ctx, headers, peerId any, opts ...any) *MockServiceFetchBodiesCall

FetchBodies indicates an expected call of FetchBodies.

func (*MockServiceMockRecorder) FetchHeaders

func (mr *MockServiceMockRecorder) FetchHeaders(ctx, start, end, peerId any, opts ...any) *MockServiceFetchHeadersCall

FetchHeaders indicates an expected call of FetchHeaders.

func (*MockServiceMockRecorder) ListPeersMayHaveBlockNum

func (mr *MockServiceMockRecorder) ListPeersMayHaveBlockNum(blockNum any) *MockServiceListPeersMayHaveBlockNumCall

ListPeersMayHaveBlockNum indicates an expected call of ListPeersMayHaveBlockNum.

func (*MockServiceMockRecorder) ListPeersMayMissBlockHash

func (mr *MockServiceMockRecorder) ListPeersMayMissBlockHash(blockHash any) *MockServiceListPeersMayMissBlockHashCall

ListPeersMayMissBlockHash indicates an expected call of ListPeersMayMissBlockHash.

func (*MockServiceMockRecorder) MaxPeers

MaxPeers indicates an expected call of MaxPeers.

func (*MockServiceMockRecorder) PeerConnected

func (mr *MockServiceMockRecorder) PeerConnected(peerId any) *MockServicePeerConnectedCall

PeerConnected indicates an expected call of PeerConnected.

func (*MockServiceMockRecorder) PeerDisconnected

func (mr *MockServiceMockRecorder) PeerDisconnected(peerId any) *MockServicePeerDisconnectedCall

PeerDisconnected indicates an expected call of PeerDisconnected.

func (*MockServiceMockRecorder) Penalize

func (mr *MockServiceMockRecorder) Penalize(ctx, peerId any) *MockServicePenalizeCall

Penalize indicates an expected call of Penalize.

func (*MockServiceMockRecorder) PublishNewBlock

func (mr *MockServiceMockRecorder) PublishNewBlock(block, td any) *MockServicePublishNewBlockCall

PublishNewBlock indicates an expected call of PublishNewBlock.

func (*MockServiceMockRecorder) PublishNewBlockHashes

func (mr *MockServiceMockRecorder) PublishNewBlockHashes(block any) *MockServicePublishNewBlockHashesCall

PublishNewBlockHashes indicates an expected call of PublishNewBlockHashes.

func (*MockServiceMockRecorder) RegisterBlockBodiesObserver

func (mr *MockServiceMockRecorder) RegisterBlockBodiesObserver(observer any) *MockServiceRegisterBlockBodiesObserverCall

RegisterBlockBodiesObserver indicates an expected call of RegisterBlockBodiesObserver.

func (*MockServiceMockRecorder) RegisterBlockHeadersObserver

func (mr *MockServiceMockRecorder) RegisterBlockHeadersObserver(observer any) *MockServiceRegisterBlockHeadersObserverCall

RegisterBlockHeadersObserver indicates an expected call of RegisterBlockHeadersObserver.

func (*MockServiceMockRecorder) RegisterNewBlockHashesObserver

func (mr *MockServiceMockRecorder) RegisterNewBlockHashesObserver(observer any) *MockServiceRegisterNewBlockHashesObserverCall

RegisterNewBlockHashesObserver indicates an expected call of RegisterNewBlockHashesObserver.

func (*MockServiceMockRecorder) RegisterNewBlockObserver

func (mr *MockServiceMockRecorder) RegisterNewBlockObserver(observer any) *MockServiceRegisterNewBlockObserverCall

RegisterNewBlockObserver indicates an expected call of RegisterNewBlockObserver.

func (*MockServiceMockRecorder) RegisterPeerEventObserver

func (mr *MockServiceMockRecorder) RegisterPeerEventObserver(observer any) *MockServiceRegisterPeerEventObserverCall

RegisterPeerEventObserver indicates an expected call of RegisterPeerEventObserver.

func (*MockServiceMockRecorder) Run

Run indicates an expected call of Run.

type MockServicePeerConnectedCall

type MockServicePeerConnectedCall struct {
	*gomock.Call
}

MockServicePeerConnectedCall wrap *gomock.Call

func (*MockServicePeerConnectedCall) Do

Do rewrite *gomock.Call.Do

func (*MockServicePeerConnectedCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServicePeerConnectedCall) Return

Return rewrite *gomock.Call.Return

type MockServicePeerDisconnectedCall

type MockServicePeerDisconnectedCall struct {
	*gomock.Call
}

MockServicePeerDisconnectedCall wrap *gomock.Call

func (*MockServicePeerDisconnectedCall) Do

Do rewrite *gomock.Call.Do

func (*MockServicePeerDisconnectedCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServicePeerDisconnectedCall) Return

Return rewrite *gomock.Call.Return

type MockServicePenalizeCall

type MockServicePenalizeCall struct {
	*gomock.Call
}

MockServicePenalizeCall wrap *gomock.Call

func (*MockServicePenalizeCall) Do

Do rewrite *gomock.Call.Do

func (*MockServicePenalizeCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServicePenalizeCall) Return

Return rewrite *gomock.Call.Return

type MockServicePublishNewBlockCall

type MockServicePublishNewBlockCall struct {
	*gomock.Call
}

MockServicePublishNewBlockCall wrap *gomock.Call

func (*MockServicePublishNewBlockCall) Do

Do rewrite *gomock.Call.Do

func (*MockServicePublishNewBlockCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServicePublishNewBlockCall) Return

Return rewrite *gomock.Call.Return

type MockServicePublishNewBlockHashesCall

type MockServicePublishNewBlockHashesCall struct {
	*gomock.Call
}

MockServicePublishNewBlockHashesCall wrap *gomock.Call

func (*MockServicePublishNewBlockHashesCall) Do

Do rewrite *gomock.Call.Do

func (*MockServicePublishNewBlockHashesCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServicePublishNewBlockHashesCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRegisterBlockBodiesObserverCall

type MockServiceRegisterBlockBodiesObserverCall struct {
	*gomock.Call
}

MockServiceRegisterBlockBodiesObserverCall wrap *gomock.Call

func (*MockServiceRegisterBlockBodiesObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRegisterBlockBodiesObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRegisterBlockBodiesObserverCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRegisterBlockHeadersObserverCall

type MockServiceRegisterBlockHeadersObserverCall struct {
	*gomock.Call
}

MockServiceRegisterBlockHeadersObserverCall wrap *gomock.Call

func (*MockServiceRegisterBlockHeadersObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRegisterBlockHeadersObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRegisterBlockHeadersObserverCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRegisterNewBlockHashesObserverCall

type MockServiceRegisterNewBlockHashesObserverCall struct {
	*gomock.Call
}

MockServiceRegisterNewBlockHashesObserverCall wrap *gomock.Call

func (*MockServiceRegisterNewBlockHashesObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRegisterNewBlockHashesObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRegisterNewBlockHashesObserverCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRegisterNewBlockObserverCall

type MockServiceRegisterNewBlockObserverCall struct {
	*gomock.Call
}

MockServiceRegisterNewBlockObserverCall wrap *gomock.Call

func (*MockServiceRegisterNewBlockObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRegisterNewBlockObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRegisterNewBlockObserverCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRegisterPeerEventObserverCall

type MockServiceRegisterPeerEventObserverCall struct {
	*gomock.Call
}

MockServiceRegisterPeerEventObserverCall wrap *gomock.Call

func (*MockServiceRegisterPeerEventObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRegisterPeerEventObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRegisterPeerEventObserverCall) Return

Return rewrite *gomock.Call.Return

type MockServiceRunCall

type MockServiceRunCall struct {
	*gomock.Call
}

MockServiceRunCall wrap *gomock.Call

func (*MockServiceRunCall) Do

Do rewrite *gomock.Call.Do

func (*MockServiceRunCall) DoAndReturn

func (c *MockServiceRunCall) DoAndReturn(f func(context.Context) error) *MockServiceRunCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockServiceRunCall) Return

func (c *MockServiceRunCall) Return(arg0 error) *MockServiceRunCall

Return rewrite *gomock.Call.Return

type MockpeerEventRegistrar

type MockpeerEventRegistrar struct {
	// contains filtered or unexported fields
}

MockpeerEventRegistrar is a mock of peerEventRegistrar interface.

func NewMockpeerEventRegistrar

func NewMockpeerEventRegistrar(ctrl *gomock.Controller) *MockpeerEventRegistrar

NewMockpeerEventRegistrar creates a new mock instance.

func (*MockpeerEventRegistrar) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockpeerEventRegistrar) RegisterNewBlockHashesObserver

RegisterNewBlockHashesObserver mocks base method.

func (*MockpeerEventRegistrar) RegisterNewBlockObserver

RegisterNewBlockObserver mocks base method.

func (*MockpeerEventRegistrar) RegisterPeerEventObserver

func (m *MockpeerEventRegistrar) RegisterPeerEventObserver(observer polygoncommon.Observer[*sentryproto.PeerEvent]) UnregisterFunc

RegisterPeerEventObserver mocks base method.

type MockpeerEventRegistrarMockRecorder

type MockpeerEventRegistrarMockRecorder struct {
	// contains filtered or unexported fields
}

MockpeerEventRegistrarMockRecorder is the mock recorder for MockpeerEventRegistrar.

func (*MockpeerEventRegistrarMockRecorder) RegisterNewBlockHashesObserver

RegisterNewBlockHashesObserver indicates an expected call of RegisterNewBlockHashesObserver.

func (*MockpeerEventRegistrarMockRecorder) RegisterNewBlockObserver

RegisterNewBlockObserver indicates an expected call of RegisterNewBlockObserver.

func (*MockpeerEventRegistrarMockRecorder) RegisterPeerEventObserver

RegisterPeerEventObserver indicates an expected call of RegisterPeerEventObserver.

type MockpeerEventRegistrarRegisterNewBlockHashesObserverCall

type MockpeerEventRegistrarRegisterNewBlockHashesObserverCall struct {
	*gomock.Call
}

MockpeerEventRegistrarRegisterNewBlockHashesObserverCall wrap *gomock.Call

func (*MockpeerEventRegistrarRegisterNewBlockHashesObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockpeerEventRegistrarRegisterNewBlockHashesObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockpeerEventRegistrarRegisterNewBlockHashesObserverCall) Return

Return rewrite *gomock.Call.Return

type MockpeerEventRegistrarRegisterNewBlockObserverCall

type MockpeerEventRegistrarRegisterNewBlockObserverCall struct {
	*gomock.Call
}

MockpeerEventRegistrarRegisterNewBlockObserverCall wrap *gomock.Call

func (*MockpeerEventRegistrarRegisterNewBlockObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockpeerEventRegistrarRegisterNewBlockObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockpeerEventRegistrarRegisterNewBlockObserverCall) Return

Return rewrite *gomock.Call.Return

type MockpeerEventRegistrarRegisterPeerEventObserverCall

type MockpeerEventRegistrarRegisterPeerEventObserverCall struct {
	*gomock.Call
}

MockpeerEventRegistrarRegisterPeerEventObserverCall wrap *gomock.Call

func (*MockpeerEventRegistrarRegisterPeerEventObserverCall) Do

Do rewrite *gomock.Call.Do

func (*MockpeerEventRegistrarRegisterPeerEventObserverCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockpeerEventRegistrarRegisterPeerEventObserverCall) Return

Return rewrite *gomock.Call.Return

type MockpeerProvider

type MockpeerProvider struct {
	// contains filtered or unexported fields
}

MockpeerProvider is a mock of peerProvider interface.

func NewMockpeerProvider

func NewMockpeerProvider(ctrl *gomock.Controller) *MockpeerProvider

NewMockpeerProvider creates a new mock instance.

func (*MockpeerProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockpeerProvider) Peers

Peers mocks base method.

type MockpeerProviderMockRecorder

type MockpeerProviderMockRecorder struct {
	// contains filtered or unexported fields
}

MockpeerProviderMockRecorder is the mock recorder for MockpeerProvider.

func (*MockpeerProviderMockRecorder) Peers

func (mr *MockpeerProviderMockRecorder) Peers(ctx, in any, opts ...any) *MockpeerProviderPeersCall

Peers indicates an expected call of Peers.

type MockpeerProviderPeersCall

type MockpeerProviderPeersCall struct {
	*gomock.Call
}

MockpeerProviderPeersCall wrap *gomock.Call

func (*MockpeerProviderPeersCall) Do

Do rewrite *gomock.Call.Do

func (*MockpeerProviderPeersCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockpeerProviderPeersCall) Return

Return rewrite *gomock.Call.Return

type PeerId

type PeerId [64]byte

func PeerIdFromEnode

func PeerIdFromEnode(url string) (*PeerId, error)

func PeerIdFromH512

func PeerIdFromH512(h512 *typesproto.H512) *PeerId

func PeerIdFromUint64

func PeerIdFromUint64(num uint64) *PeerId

PeerIdFromUint64 is useful for testing and that is its main intended purpose

func (*PeerId) Equal

func (pid *PeerId) Equal(other *PeerId) bool

func (*PeerId) H512

func (pid *PeerId) H512() *typesproto.H512

func (*PeerId) String

func (pid *PeerId) String() string

type PeerPenalizer

type PeerPenalizer interface {
	Penalize(ctx context.Context, peerId *PeerId) error
}

func NewPeerPenalizer

func NewPeerPenalizer(sentryClient sentry.SentryClient) PeerPenalizer

type PeerShuffle

type PeerShuffle func(peerIds []*PeerId)

type PeerTracker

type PeerTracker interface {
	Run(ctx context.Context) error
	ListPeersMayHaveBlockNum(blockNum uint64) []*PeerId
	BlockNumPresent(peerId *PeerId, blockNum uint64)
	BlockNumMissing(peerId *PeerId, blockNum uint64)
	ListPeersMayMissBlockHash(blockHash common.Hash) []*PeerId
	BlockHashPresent(peerId *PeerId, blockHash common.Hash)
	PeerConnected(peerId *PeerId)
	PeerDisconnected(peerId *PeerId)
}

func NewPeerTracker

func NewPeerTracker(
	logger log.Logger,
	peerProvider peerProvider,
	peerEventRegistrar peerEventRegistrar,
	opts ...PeerTrackerOption,
) PeerTracker

type PeerTrackerOption

type PeerTrackerOption func(*peerTracker)

type Publisher

type Publisher interface {
	PublishNewBlock(block *types.Block, td *big.Int)
	PublishNewBlockHashes(block *types.Block)
	Run(ctx context.Context) error
}

func NewPublisher

func NewPublisher(logger log.Logger, messageSender MessageSender, peerTracker PeerTracker) Publisher

type RequestIdGenerator

type RequestIdGenerator func() uint64

type Service

type Service interface {
	Fetcher
	MessageListener
	PeerTracker
	PeerPenalizer
	Publisher
	Run(ctx context.Context) error
	MaxPeers() int
}

func NewService

func NewService(
	maxPeers int,
	logger log.Logger,
	sentryClient sentryproto.SentryClient,
	statusDataFactory sentry.StatusDataFactory,
) Service

type UnregisterFunc

type UnregisterFunc = polygoncommon.UnregisterFunc

Jump to

Keyboard shortcuts

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