hot

package
v0.31.5-binance.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// the type of samples, Good means get sample result in limit time, otherwise is Bad event.
	Bad eventType = iota
	Good
)
View Source
const (
	// HotBlockchainChannel is a channel for blocks/commits and status updates under hot sync mode.
	HotBlockchainChannel = byte(0x41)
)
View Source
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 NewBlockState(height int64, logger log.Logger, pool *BlockPool) *blockState

func NewPeerPublisherState

func NewPeerPublisherState(bc *blockState, pid p2p.ID, logger log.Logger, timeoutDur time.Duration, pool *BlockPool) *publisherState

func RegisterHotBlockchainMessages

func RegisterHotBlockchainMessages(cdc *amino.Codec)

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) AddPeer

func (pool *BlockPool) AddPeer(peer p2p.Peer)

func (*BlockPool) OnStart

func (pool *BlockPool) OnStart() error

---------------Service implement ----------------

func (*BlockPool) OnStop

func (pool *BlockPool) OnStop()

func (*BlockPool) RemovePeer

func (pool *BlockPool) RemovePeer(peer p2p.Peer)

func (*BlockPool) SetLogger

func (pool *BlockPool) SetLogger(l log.Logger)

func (*BlockPool) SwitchToConsensusSync

func (pool *BlockPool) SwitchToConsensusSync(state *st.State)

func (*BlockPool) SwitchToHotSync

func (pool *BlockPool) SwitchToHotSync(state st.State, blockSynced int32)

------ switch logic -----

type BlockchainMessage

type BlockchainMessage interface {
	ValidateBasic() error
	String() string
}

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 NopMetrics

func NopMetrics() *Metrics

NopMetrics returns no-op Metrics.

func PrometheusMetrics

func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics

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
)

Jump to

Keyboard shortcuts

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