sync2

package
v1.3.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataRequestEntryLimit    = 20
	DataRequestNodeLimit     = 3
	DataRequestNodeInterval  = time.Millisecond * 300
	DataRequestRoundInterval = time.Second * 3
)
View Source
const (
	NoError errCode = iota
	ErrTimeExpired
	ErrNoData
)

Variables

This section is empty.

Functions

func PeerIDToKey

func PeerIDToKey(p module.PeerID) string

Types

type BucketIDAndBytes

type BucketIDAndBytes struct {
	BkID  db.BucketID
	Bytes []byte
}

func (BucketIDAndBytes) String

func (b BucketIDAndBytes) String() string

type DataHandler

type DataHandler func(reqID uint32, sender *peer, data []BucketIDAndBytes)

type DataSender

type DataSender interface {
	RequestData(peer module.PeerID, reqID uint32, reqData []BucketIDAndBytes) error
}

type Manager

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

func NewSyncManager

func NewSyncManager(database db.Database, nm module.NetworkManager, plt Platform, logger log.Logger) *Manager

func (*Manager) AddRequest

func (m *Manager) AddRequest(id db.BucketID, key []byte) error

func (*Manager) NewSyncer

func (m *Manager) NewSyncer(ah, prh, nrh, vh, ed, bh []byte, noBuffer bool) Syncer

func (*Manager) Start

func (m *Manager) Start()

func (*Manager) Term

func (m *Manager) Term()

func (*Manager) UnresolvedRequestCount

func (m *Manager) UnresolvedRequestCount() int

type PeerWatcher

type PeerWatcher interface {
	OnPeerJoin(p *peer)
	OnPeerLeave(p *peer)
}

type Platform

type Platform interface {
	NewExtensionWithBuilder(builder merkle.Builder, raw []byte) state.ExtensionSnapshot
}

type ReactorCommon

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

func (*ReactorCommon) GetVersion

func (r *ReactorCommon) GetVersion() byte

func (*ReactorCommon) OnJoin

func (r *ReactorCommon) OnJoin(id module.PeerID)

func (*ReactorCommon) OnLeave

func (r *ReactorCommon) OnLeave(id module.PeerID)

func (*ReactorCommon) UnwatchPeers

func (r *ReactorCommon) UnwatchPeers(watcher PeerWatcher) bool

func (*ReactorCommon) WatchPeers

func (r *ReactorCommon) WatchPeers(watcher PeerWatcher) []*peer

type ReactorV1

type ReactorV1 struct {
	ReactorCommon
	// contains filtered or unexported fields
}

func (*ReactorV1) OnFailure

func (r *ReactorV1) OnFailure(err error, pi module.ProtocolInfo, b []byte)

func (*ReactorV1) OnReceive

func (r *ReactorV1) OnReceive(pi module.ProtocolInfo, b []byte, id module.PeerID) (bool, error)

func (*ReactorV1) RequestData

func (r *ReactorV1) RequestData(peer module.PeerID, reqID uint32, reqData []BucketIDAndBytes) error

type ReactorV2

type ReactorV2 struct {
	ReactorCommon
	// contains filtered or unexported fields
}

func (*ReactorV2) OnFailure

func (r *ReactorV2) OnFailure(err error, pi module.ProtocolInfo, b []byte)

func (*ReactorV2) OnReceive

func (r *ReactorV2) OnReceive(pi module.ProtocolInfo, b []byte, id module.PeerID) (bool, error)

func (*ReactorV2) RequestData

func (r *ReactorV2) RequestData(peer module.PeerID, reqID uint32, reqData []BucketIDAndBytes) error

type RequestCallback

type RequestCallback func(ver byte, dataLen int, id module.PeerID)

type Result

type Result struct {
	Wss            state.WorldSnapshot
	PatchReceipts  module.ReceiptList
	NormalReceipts module.ReceiptList
	BTPDigest      module.BTPDigest
}

type SyncProcessor

type SyncProcessor interface {
	Start(cb func(err error))
	Stop()
	AddRequest(id db.BucketID, key []byte) error
	UnresolvedCount() int
}

type SyncReactor

type SyncReactor interface {
	GetVersion() byte
	WatchPeers(watcher PeerWatcher) []*peer
	UnwatchPeers(watcher PeerWatcher) bool
}

type Syncer

type Syncer interface {
	ForceSync() (*Result, error)
	Stop()
	Finalize() error
}

Jump to

Keyboard shortcuts

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