Documentation
¶
Index ¶
- Constants
- func NewBlockState(height int64, logger log.Logger, pool *BlockPool) *blockState
- func NewPeerPublisherState(bc *blockState, pid p2p.ID, logger log.Logger, timeoutDur time.Duration, ...) *publisherState
- func RegisterHotBlockchainMessages(cdc *amino.Codec)
- type BlockChainOption
- type BlockPool
- func (pool *BlockPool) AddPeer(peer p2p.Peer)
- func (pool *BlockPool) OnStart() error
- func (pool *BlockPool) OnStop()
- func (pool *BlockPool) RemovePeer(peer p2p.Peer)
- func (pool *BlockPool) SetLogger(l log.Logger)
- func (pool *BlockPool) SwitchToConsensusSync(state *st.State)
- func (pool *BlockPool) SwitchToHotSync(state st.State, blockSynced int32)
- type BlockchainMessage
- type BlockchainReactor
- func (hbcR *BlockchainReactor) AddPeer(peer p2p.Peer)
- func (hbcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
- func (hbcR *BlockchainReactor) OnStart() error
- func (hbcR *BlockchainReactor) OnStop()
- func (hbcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
- func (hbcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (hbcR *BlockchainReactor) SetLogger(l log.Logger)
- func (hbcR *BlockchainReactor) SetPrivValidator(priv types.PrivValidator)
- func (hbcR *BlockchainReactor) SetSwitch(sw *p2p.Switch)
- func (hbcR *BlockchainReactor) SwitchToConsensusSync(state sm.State)
- func (hbcR *BlockchainReactor) SwitchToHotSync(state sm.State, blockSynced int32)
- type CandidatePool
- type Message
- type Metrics
- type SyncPattern
Constants ¶
const ( // the type of samples, Good means get sample result in limit time, otherwise is Bad event. Bad eventType = iota Good )
const ( // HotBlockchainChannel is a channel for blocks/commits and status updates under hot sync mode. HotBlockchainChannel = byte(0x41) )
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "hot_sync" )
Variables ¶
This section is empty.
Functions ¶
func NewBlockState ¶
func NewPeerPublisherState ¶
Types ¶
type BlockChainOption ¶
type BlockChainOption func(*BlockchainReactor)
func WithEventBus ¶
func WithEventBus(eventBs *types.EventBus) BlockChainOption
WithMetrics sets the metrics.
func WithMetrics ¶
func WithMetrics(metrics *Metrics) BlockChainOption
WithMetrics sets the metrics.
type BlockPool ¶
type BlockPool struct {
cmn.BaseService
// contains filtered or unexported fields
}
func NewBlockPool ¶
func NewBlockPool(store *blockchain.BlockStore, blockExec *st.BlockExecutor, state st.State, sendCh chan<- Message, st SyncPattern, blockTimeout time.Duration) *BlockPool
func (*BlockPool) RemovePeer ¶
func (*BlockPool) SwitchToConsensusSync ¶
type BlockchainMessage ¶
BlockchainMessage is a generic message for this reactor.
type BlockchainReactor ¶
type BlockchainReactor struct {
p2p.BaseReactor
// contains filtered or unexported fields
}
BlockchainReactor handles low latency catchup when there is small lag.
func NewBlockChainReactor ¶
func NewBlockChainReactor(state sm.State, blockExec *sm.BlockExecutor, store *blockchain.BlockStore, hotSync, fastSync bool, blockTimeout time.Duration, options ...BlockChainOption) *BlockchainReactor
NewBlockChainReactor returns new reactor instance.
func (*BlockchainReactor) AddPeer ¶
func (hbcR *BlockchainReactor) AddPeer(peer p2p.Peer)
func (*BlockchainReactor) GetChannels ¶
func (hbcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor
func (*BlockchainReactor) OnStart ¶
func (hbcR *BlockchainReactor) OnStart() error
OnStart implements cmn.Service.
func (*BlockchainReactor) OnStop ¶
func (hbcR *BlockchainReactor) OnStop()
OnStop implements cmn.Service.
func (*BlockchainReactor) Receive ¶
func (hbcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
Receive implements Reactor by handling 5 types of messages (look below).
func (*BlockchainReactor) RemovePeer ¶
func (hbcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
func (*BlockchainReactor) SetLogger ¶
func (hbcR *BlockchainReactor) SetLogger(l log.Logger)
SetLogger implements cmn.Service by setting the logger on reactor and pool.
func (*BlockchainReactor) SetPrivValidator ¶
func (hbcR *BlockchainReactor) SetPrivValidator(priv types.PrivValidator)
func (*BlockchainReactor) SetSwitch ¶
func (hbcR *BlockchainReactor) SetSwitch(sw *p2p.Switch)
func (*BlockchainReactor) SwitchToConsensusSync ¶
func (hbcR *BlockchainReactor) SwitchToConsensusSync(state sm.State)
func (*BlockchainReactor) SwitchToHotSync ¶
func (hbcR *BlockchainReactor) SwitchToHotSync(state sm.State, blockSynced int32)
type CandidatePool ¶
type CandidatePool struct {
cmn.BaseService
// contains filtered or unexported fields
}
func NewCandidatePool ¶
func NewCandidatePool(eventStream <-chan metricsEvent) *CandidatePool
func (*CandidatePool) OnStart ¶
func (c *CandidatePool) OnStart() error
OnStart implements cmn.Service.
func (*CandidatePool) PickCandidates ¶
func (c *CandidatePool) PickCandidates() []*p2p.ID
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
-----------------------
type Metrics ¶
type Metrics struct {
// Height of the chain.
Height metrics.Gauge
// Time between this and the last block.
BlockIntervalSeconds metrics.Gauge
// Number of transactions.
NumTxs metrics.Gauge
// Size of the block.
BlockSizeBytes metrics.Gauge
// Total number of transactions.
TotalTxs metrics.Gauge
// The latest block height.
CommittedHeight metrics.Gauge
// The number of peers consider as good
PermanentPeerSetSize metrics.Gauge
// The detail peers consider as good
PermanentPeers metrics.Gauge
// The number of peers consider as bad
DecayPeerSetSize metrics.Gauge
}
Metrics contains metrics exposed by this package.
func PrometheusMetrics ¶
PrometheusMetrics returns Metrics build using Prometheus client library. Optionally, labels can be provided along with their values ("foo", "fooValue").
type SyncPattern ¶
type SyncPattern uint
const ( // SyncPattern is the work pattern of BlockPool. // 1. Mute: will only answer subscribe requests from others, will not sync from others or from consensus channel. // 2. Hot: handle subscribe requests from other peer as a publisher, also subscribe block messages // from other peers as a subscriber. // 3. Consensus: handle subscribe requests from other peer as a publisher, but subscribe block message from // consensus channel. // The viable transitions between are: // Hot --> Consensus // ^ ^ // | / // | / // Mute Mute SyncPattern = iota Hot Consensus )