download

package
v0.0.0-...-215623d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrpcSentryClient

func GrpcSentryClient(ctx context.Context, sentryAddr string) (proto_sentry.SentryClient, error)

func Loop

func Loop(ctx context.Context, db ethdb.Database, sync *stagedsync.StagedSync, controlServer *ControlServerImpl, notifier stagedsync.ChainEventNotifier, waitForDone chan struct{})

Deprecated - use stages.StageLoop

func MakeProtocols

func MakeProtocols(ctx context.Context,
	readNodeInfo func() *eth.NodeInfo,
	dialCandidates enode.Iterator,
	peers *sync.Map,
	statusFn func() *proto_sentry.StatusData,
	receiveCh chan<- StreamMsg,
	receiveUploadCh chan<- StreamMsg,
	receiveTxCh chan<- StreamMsg,
) []p2p.Protocol

func NewStagedSync

func NewStagedSync(
	ctx context.Context,
	db ethdb.RwKV,
	sm ethdb.StorageMode,
	batchSize datasize.ByteSize,
	bodyDownloadTimeout int,
	controlServer *ControlServerImpl,
	tmpdir string,
	txPool *core.TxPool,
	txPoolServer *eth.TxPoolServer,
) (*stagedsync.StagedSync, error)

func RecvMessage

func RecvMessage(ctx context.Context, sentry proto_sentry.SentryClient, handleInboundMessage func(ctx context.Context, inreq *proto_sentry.InboundMessage, sentry proto_sentry.SentryClient) error)

func RecvUploadMessage

func RecvUploadMessage(ctx context.Context, sentry proto_sentry.SentryClient, handleInboundMessage func(ctx context.Context, inreq *proto_sentry.InboundMessage, sentry proto_sentry.SentryClient) error)

func Sentry

func Sentry(datadir string, natSetting string, port int, sentryAddr string, staticPeers []string, discovery bool, netRestrict string) error

Sentry creates and runs standalone sentry

func SetSentryStatus

func SetSentryStatus(ctx context.Context, sentries []proto_sentry.SentryClient, controlServer *ControlServerImpl) error

Types

type ControlServerImpl

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

func NewControlServer

func NewControlServer(db ethdb.RwKV, nodeName string, chainConfig *params.ChainConfig, genesisHash common.Hash, engine consensus.Engine, networkID uint64, sentries []proto_sentry.SentryClient, window int) (*ControlServerImpl, error)

func (*ControlServerImpl) BroadcastNewBlock

func (cs *ControlServerImpl) BroadcastNewBlock(ctx context.Context, block *types.Block, td *big.Int)

func (*ControlServerImpl) HandleInboundMessage

func (cs *ControlServerImpl) HandleInboundMessage(ctx context.Context, inreq *proto_sentry.InboundMessage, sentry proto_sentry.SentryClient) error

func (*ControlServerImpl) PropagateNewBlockHashes

func (cs *ControlServerImpl) PropagateNewBlockHashes(ctx context.Context, announces []headerdownload.Announce)

type PeerInfo

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

PeerInfo collects various extra bits of information about the peer, for example deadlines that is used for regulating requests sent to the peer

func (*PeerInfo) AddDeadline

func (pi *PeerInfo) AddDeadline(deadline time.Time)

AddDeadline adds given deadline to the list of deadlines Deadlines must be added in the chronological order for the function ClearDeadlines to work correctly (it uses binary search)

func (*PeerInfo) ClearDeadlines

func (pi *PeerInfo) ClearDeadlines(now time.Time, givePermit bool) int

ClearDeadlines goes through the deadlines of given peers and removes the ones that have passed Optionally, it also clears one extra deadline - this is used when response is received It returns the number of deadlines left

func (*PeerInfo) Remove

func (pi *PeerInfo) Remove()

func (*PeerInfo) Removed

func (pi *PeerInfo) Removed() bool

type SentryClientDirect

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

SentryClientDirect implements SentryClient interface by connecting the instance of the client directly with the corresponding instance of SentryServer

func (*SentryClientDirect) PeerMinBlock

func (*SentryClientDirect) PenalizePeer

func (*SentryClientDirect) ReceiveMessages

func (*SentryClientDirect) ReceiveTxMessages

func (*SentryClientDirect) ReceiveUploadMessages

func (*SentryClientDirect) SendMessageById

func (*SentryClientDirect) SendMessageByMinBlock

func (*SentryClientDirect) SendMessageToAll

func (*SentryClientDirect) SendMessageToRandomPeers

func (*SentryClientDirect) SetServer

func (scd *SentryClientDirect) SetServer(sentryServer proto_sentry.SentryServer)

SetServer injects a reference to the SentryServer into the client

func (*SentryClientDirect) SetStatus

type SentryReceiveClientDirect

type SentryReceiveClientDirect struct {
	grpc.ClientStream
	// contains filtered or unexported fields
}

func (*SentryReceiveClientDirect) Recv

type SentryReceiveServerDirect

type SentryReceiveServerDirect struct {
	grpc.ServerStream
	// contains filtered or unexported fields
}

implements proto_sentry.Sentry_ReceiveMessagesServer

func (*SentryReceiveServerDirect) Send

type SentryServerImpl

type SentryServerImpl struct {
	proto_sentry.UnimplementedSentryServer

	Peers sync.Map

	P2pServer *p2p.Server

	ReceiveCh chan StreamMsg

	ReceiveUploadCh chan StreamMsg

	ReceiveTxCh chan StreamMsg
	// contains filtered or unexported fields
}

func NewSentryServer

func NewSentryServer(ctx context.Context, datadir string, p2pListenAddr string) *SentryServerImpl

func (*SentryServerImpl) GetStatus

func (ss *SentryServerImpl) GetStatus() *proto_sentry.StatusData

func (*SentryServerImpl) PeerMinBlock

func (*SentryServerImpl) PenalizePeer

func (*SentryServerImpl) ReceiveMessages

func (*SentryServerImpl) ReceiveTxMessages

func (*SentryServerImpl) ReceiveUploadMessages

func (*SentryServerImpl) SendMessageById

func (*SentryServerImpl) SendMessageByMinBlock

func (*SentryServerImpl) SendMessageToAll

func (*SentryServerImpl) SendMessageToRandomPeers

func (*SentryServerImpl) SetStatus

func (ss *SentryServerImpl) SetStatus(_ context.Context, statusData *proto_sentry.StatusData) (*emptypb.Empty, error)

type StreamMsg

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

Jump to

Keyboard shortcuts

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