chainmgr

package
v4.8.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain interface {
	BestBlockHeader() *types.BlockHeader
	LastIrreversibleHeader() *types.BlockHeader
	BestBlockHeight() uint64
	GetBlockByHash(*bc.Hash) (*types.Block, error)
	GetBlockByHeight(uint64) (*types.Block, error)
	GetHeaderByHash(*bc.Hash) (*types.BlockHeader, error)
	GetHeaderByHeight(uint64) (*types.BlockHeader, error)
	GetTransactionStatus(*bc.Hash) (*bc.TransactionStatus, error)
	InMainChain(bc.Hash) bool
	ProcessBlock(*types.Block) (bool, error)
	ValidateTx(*types.Tx) (bool, error)
}

Chain is the interface for Bytom core

type Fetcher added in v0.2.0

type Fetcher interface {
	// contains filtered or unexported methods
}

Fetcher is the interface for fetch struct

type LocalStore added in v0.3.0

type LocalStore interface {
	// contains filtered or unexported methods
}

LocalStore is the interface for persistent storage

type Manager

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

Manager is responsible for the business layer information synchronization

func NewManager

func NewManager(config *cfg.Config, sw Switch, chain Chain, mempool Mempool, dispatcher *event.Dispatcher, peers *peers.PeerSet, fastSyncDB dbm.DB) (*Manager, error)

NewManager create a chain sync manager.

func (*Manager) AddPeer

func (m *Manager) AddPeer(peer peers.BasePeer)

AddPeer add the network layer peer to logic layer

func (*Manager) IsCaughtUp

func (m *Manager) IsCaughtUp() bool

IsCaughtUp check wheather the peer finish the sync

func (*Manager) RemovePeer

func (m *Manager) RemovePeer(peerID string)

RemovePeer delete peer for peer set

func (*Manager) SendStatus

func (m *Manager) SendStatus(peer peers.BasePeer) error

SendStatus sent the current self status to remote peer

func (*Manager) Start

func (m *Manager) Start() error

Start the network logic layer

func (*Manager) Stop

func (m *Manager) Stop()

Stop stop sync manager

type Mempool

type Mempool interface {
	GetTransactions() []*core.TxDesc
	IsDust(tx *types.Tx) bool
}

Mempool is the interface for Bytom mempool

type MsgFetcher added in v0.2.0

type MsgFetcher interface {
	// contains filtered or unexported methods
}

MsgFetcher is the interface for msg fetch struct

type ProtocolReactor

type ProtocolReactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

ProtocolReactor handles new coming protocol message.

func NewProtocolReactor

func NewProtocolReactor(manager *Manager) *ProtocolReactor

NewProtocolReactor returns the reactor of whole blockchain.

func (*ProtocolReactor) AddPeer

func (pr *ProtocolReactor) AddPeer(peer *p2p.Peer) error

AddPeer implements Reactor by sending our state to peer.

func (*ProtocolReactor) GetChannels

func (pr *ProtocolReactor) GetChannels() []*connection.ChannelDescriptor

GetChannels implements Reactor

func (*ProtocolReactor) OnStart

func (pr *ProtocolReactor) OnStart() error

OnStart implements BaseService

func (*ProtocolReactor) OnStop

func (pr *ProtocolReactor) OnStop()

OnStop implements BaseService

func (*ProtocolReactor) Receive

func (pr *ProtocolReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)

Receive implements Reactor by handling 4 types of messages (look below).

func (*ProtocolReactor) RemovePeer

func (pr *ProtocolReactor) RemovePeer(peer *p2p.Peer, reason interface{})

RemovePeer implements Reactor by removing peer from the pool.

type Switch

type Switch interface {
	AddReactor(name string, reactor p2p.Reactor) p2p.Reactor
	Start() (bool, error)
	Stop() bool
	IsListening() bool
	DialPeerWithAddress(addr *p2p.NetAddress) error
	Peers() *p2p.PeerSet
}

Switch is the interface for network layer

Jump to

Keyboard shortcuts

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