Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(src []byte) ([]byte, error)
- func Encode(msgcode uint64, src []byte) []byte
- func NewFastSync(pm *IdenaGossipHandler, log log.Logger, chain *blockchain.Blockchain, ...) *fastSync
- func NewFullSync(pm *IdenaGossipHandler, log log.Logger, chain *blockchain.Blockchain, ...) *fullSync
- func SntpDrift(measurements int) (time.Duration, error)
- type BlockSeeker
- type ConnManager
- func (m *ConnManager) AddConnection(conn network.Conn)
- func (m *ConnManager) BanPeer(id peer.ID)
- func (m *ConnManager) CanAcceptStream() bool
- func (m *ConnManager) CanConnect(id peer.ID) bool
- func (m *ConnManager) CanDial() bool
- func (m *ConnManager) Connected(id peer.ID, inbound bool)
- func (m *ConnManager) DialRandomPeer() (network.Stream, error)
- func (m *ConnManager) Disconnected(id peer.ID, reason error)
- func (m *ConnManager) GetRandomInboundPeer() peer.ID
- func (m *ConnManager) GetRandomOutboundPeer() peer.ID
- func (m *ConnManager) RemoveConnection(conn network.Conn)
- type Downloader
- func (d *Downloader) BanPeer(peerId peer.ID, reason error)
- func (d *Downloader) ClearPotentialForks()
- func (d *Downloader) GetForkedPeers() mapset.Set
- func (d *Downloader) HasPotentialFork() bool
- func (d *Downloader) IsSyncing() bool
- func (d *Downloader) Load()
- func (d *Downloader) SeekBlocks(fromBlock, toBlock uint64, peers []peer.ID) chan *types.BlockBundle
- func (d *Downloader) SeekForkedBlocks(ownBlocks []common.Hash, peerId peer.ID) chan types.BlockBundle
- func (d *Downloader) SyncBlockchain(forkResolver ForkResolver) error
- func (d *Downloader) SyncProgress() (head uint64, top uint64)
- type ForkResolver
- type IdenaGossipHandler
- func (h *IdenaGossipHandler) AddPeer(url string) error
- func (h *IdenaGossipHandler) BanPeer(peerId peer.ID, reason error)
- func (h *IdenaGossipHandler) Endpoint() string
- func (h *IdenaGossipHandler) GetBlocksRange(peerId peer.ID, from uint64, to uint64) (*batch, error)
- func (h *IdenaGossipHandler) GetForkBlockRange(peerId peer.ID, ownBlocks []common.Hash) (*batch, error)
- func (h *IdenaGossipHandler) GetKnownHeights() map[peer.ID]uint64
- func (h *IdenaGossipHandler) GetKnownManifests() map[peer.ID]*snapshot.Manifest
- func (h *IdenaGossipHandler) HasPeers() bool
- func (h *IdenaGossipHandler) IsConnected(id peer.ID) bool
- func (h *IdenaGossipHandler) PeerHeights() []uint64
- func (h *IdenaGossipHandler) Peers() []*protoPeer
- func (h *IdenaGossipHandler) PeersCount() int
- func (h *IdenaGossipHandler) PotentialForwardPeers(round uint64) []peer.ID
- func (h *IdenaGossipHandler) ProposeBlock(block *types.BlockProposal)
- func (h *IdenaGossipHandler) ProposeProof(proposal *types.ProofProposal)
- func (h *IdenaGossipHandler) RequestBlockByHash(hash common.Hash)
- func (h *IdenaGossipHandler) SendVote(vote *types.Vote)
- func (h *IdenaGossipHandler) Start()
- func (h *IdenaGossipHandler) WrongTime() bool
- type Msg
- type PushPullManager
- func (m *PushPullManager) AddEntry(key pushPullHash, entry interface{})
- func (m *PushPullManager) AddEntryHolder(pushId pushType, holder pushpull.Holder)
- func (m *PushPullManager) GetEntry(hash pushPullHash) (interface{}, bool)
- func (m *PushPullManager) Requests() chan pullRequest
- func (m *PushPullManager) Run()
- type Syncer
Constants ¶
View Source
const ( Handshake = 0x01 ProposeBlock = 0x02 ProposeProof = 0x03 Vote = 0x04 NewTx = 0x05 GetBlockByHash = 0x06 GetBlocksRange = 0x07 BlocksRange = 0x08 FlipBody = 0x09 FlipKey = 0x0A SnapshotManifest = 0x0B GetForkBlockRange = 0x0C FlipKeysPackage = 0x0D Push = 0x0E Pull = 0x0F Block = 0x10 )
View Source
const ( DecodeErr = 1 ValidationErr = 2 MaxTimestampLagSeconds = 15 MaxBannedPeers = 500000 IdenaProtocolWeight = 25 ReconnectAfterDiscTimeout = time.Minute * 1 ReconnectAfterResetTimeout = time.Minute * 3 )
View Source
const FastSyncBatchSize = 1000
View Source
const FlushToDiskLastStates = 200
View Source
const FullSyncBatchSize = 200
View Source
const (
MaxAttemptsCountPerBatch = 10
)
Variables ¶
View Source
var (
BanReasonTimeout = errors.New("timeout")
)
View Source
var (
BlockCertIsMissing = errors.New("block cert is missing")
)
View Source
var FailedToDialPeer = errors.New("failed to select peer")
View Source
var IdenaProtocol core.ProtocolID = "/idena/gossip/1.0.0"
View Source
var NoPeersToDial = errors.New("no peers to dial")
Functions ¶
func NewFastSync ¶
func NewFastSync(pm *IdenaGossipHandler, log log.Logger, chain *blockchain.Blockchain, ipfs ipfs.Proxy, appState *appstate.AppState, potentialForkedPeers mapset.Set, manifest *snapshot.Manifest, sm *state.SnapshotManager, bus eventbus.Bus, coinbase common.Address) *fastSync
func NewFullSync ¶
func NewFullSync( pm *IdenaGossipHandler, log log.Logger, chain *blockchain.Blockchain, ipfs ipfs.Proxy, appState *appstate.AppState, potentialForkedPeers mapset.Set, targetHeight uint64, statsCollector collector.StatsCollector, ) *fullSync
func SntpDrift ¶
SntpDrift does a naive time resolution against an NTP server and returns the measured drift. This method uses the simple version of NTP. It's not precise but should be fine for these purposes.
Note, it executes two extra measurements compared to the number of requested ones to be able to discard the two extremes as outliers.
Types ¶
type BlockSeeker ¶
type BlockSeeker interface {
SeekBlocks(fromBlock, toBlock uint64, peers []peer.ID) chan *types.BlockBundle
}
type ConnManager ¶
type ConnManager struct {
// contains filtered or unexported fields
}
func NewConnManager ¶
func NewConnManager(host core.Host, cfg config.P2P) *ConnManager
func (*ConnManager) AddConnection ¶
func (m *ConnManager) AddConnection(conn network.Conn)
func (*ConnManager) BanPeer ¶
func (m *ConnManager) BanPeer(id peer.ID)
func (*ConnManager) CanAcceptStream ¶
func (m *ConnManager) CanAcceptStream() bool
func (*ConnManager) CanConnect ¶
func (m *ConnManager) CanConnect(id peer.ID) bool
func (*ConnManager) CanDial ¶
func (m *ConnManager) CanDial() bool
func (*ConnManager) DialRandomPeer ¶
func (m *ConnManager) DialRandomPeer() (network.Stream, error)
func (*ConnManager) Disconnected ¶
func (m *ConnManager) Disconnected(id peer.ID, reason error)
func (*ConnManager) GetRandomInboundPeer ¶
func (m *ConnManager) GetRandomInboundPeer() peer.ID
func (*ConnManager) GetRandomOutboundPeer ¶
func (m *ConnManager) GetRandomOutboundPeer() peer.ID
func (*ConnManager) RemoveConnection ¶
func (m *ConnManager) RemoveConnection(conn network.Conn)
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
func NewDownloader ¶
func NewDownloader( pm *IdenaGossipHandler, cfg *config.Config, chain *blockchain.Blockchain, ipfs ipfs.Proxy, appState *appstate.AppState, sm *state.SnapshotManager, bus eventbus.Bus, secStore *secstore.SecStore, statsCollector collector.StatsCollector, ) *Downloader
func (*Downloader) ClearPotentialForks ¶
func (d *Downloader) ClearPotentialForks()
func (*Downloader) GetForkedPeers ¶
func (d *Downloader) GetForkedPeers() mapset.Set
func (*Downloader) HasPotentialFork ¶
func (d *Downloader) HasPotentialFork() bool
func (*Downloader) IsSyncing ¶
func (d *Downloader) IsSyncing() bool
func (*Downloader) Load ¶
func (d *Downloader) Load()
func (*Downloader) SeekBlocks ¶
func (d *Downloader) SeekBlocks(fromBlock, toBlock uint64, peers []peer.ID) chan *types.BlockBundle
func (*Downloader) SeekForkedBlocks ¶
func (d *Downloader) SeekForkedBlocks(ownBlocks []common.Hash, peerId peer.ID) chan types.BlockBundle
func (*Downloader) SyncBlockchain ¶
func (d *Downloader) SyncBlockchain(forkResolver ForkResolver) error
func (*Downloader) SyncProgress ¶
func (d *Downloader) SyncProgress() (head uint64, top uint64)
type ForkResolver ¶
type ForkResolver interface {
HasLoadedFork() bool
}
type IdenaGossipHandler ¶
type IdenaGossipHandler struct {
// contains filtered or unexported fields
}
func NewIdenaGossipHandler ¶
func (*IdenaGossipHandler) AddPeer ¶
func (h *IdenaGossipHandler) AddPeer(url string) error
func (*IdenaGossipHandler) BanPeer ¶
func (h *IdenaGossipHandler) BanPeer(peerId peer.ID, reason error)
func (*IdenaGossipHandler) Endpoint ¶
func (h *IdenaGossipHandler) Endpoint() string
func (*IdenaGossipHandler) GetBlocksRange ¶
func (*IdenaGossipHandler) GetForkBlockRange ¶
func (*IdenaGossipHandler) GetKnownHeights ¶
func (h *IdenaGossipHandler) GetKnownHeights() map[peer.ID]uint64
func (*IdenaGossipHandler) GetKnownManifests ¶
func (h *IdenaGossipHandler) GetKnownManifests() map[peer.ID]*snapshot.Manifest
func (*IdenaGossipHandler) HasPeers ¶
func (h *IdenaGossipHandler) HasPeers() bool
func (*IdenaGossipHandler) IsConnected ¶
func (h *IdenaGossipHandler) IsConnected(id peer.ID) bool
func (*IdenaGossipHandler) PeerHeights ¶
func (h *IdenaGossipHandler) PeerHeights() []uint64
func (*IdenaGossipHandler) Peers ¶
func (h *IdenaGossipHandler) Peers() []*protoPeer
func (*IdenaGossipHandler) PeersCount ¶
func (h *IdenaGossipHandler) PeersCount() int
func (*IdenaGossipHandler) PotentialForwardPeers ¶
func (h *IdenaGossipHandler) PotentialForwardPeers(round uint64) []peer.ID
func (*IdenaGossipHandler) ProposeBlock ¶
func (h *IdenaGossipHandler) ProposeBlock(block *types.BlockProposal)
func (*IdenaGossipHandler) ProposeProof ¶
func (h *IdenaGossipHandler) ProposeProof(proposal *types.ProofProposal)
func (*IdenaGossipHandler) RequestBlockByHash ¶
func (h *IdenaGossipHandler) RequestBlockByHash(hash common.Hash)
func (*IdenaGossipHandler) SendVote ¶
func (h *IdenaGossipHandler) SendVote(vote *types.Vote)
func (*IdenaGossipHandler) Start ¶
func (h *IdenaGossipHandler) Start()
func (*IdenaGossipHandler) WrongTime ¶
func (h *IdenaGossipHandler) WrongTime() bool
type PushPullManager ¶
type PushPullManager struct {
// contains filtered or unexported fields
}
func NewPushPullManager ¶
func NewPushPullManager() *PushPullManager
func (*PushPullManager) AddEntry ¶
func (m *PushPullManager) AddEntry(key pushPullHash, entry interface{})
func (*PushPullManager) AddEntryHolder ¶
func (m *PushPullManager) AddEntryHolder(pushId pushType, holder pushpull.Holder)
func (*PushPullManager) GetEntry ¶
func (m *PushPullManager) GetEntry(hash pushPullHash) (interface{}, bool)
func (*PushPullManager) Requests ¶
func (m *PushPullManager) Requests() chan pullRequest
func (*PushPullManager) Run ¶ added in v0.19.5
func (m *PushPullManager) Run()
Click to show internal directories.
Click to hide internal directories.