consensusmgr

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockProposeMsg

type BlockProposeMsg struct {
	RawBlock []byte
}

BlockProposeMsg block propose message transferred between nodes.

func (*BlockProposeMsg) BroadcastFilterTargetPeers

func (bp *BlockProposeMsg) BroadcastFilterTargetPeers(ps *peers.PeerSet) []string

BroadcastFilterTargetPeers filter target peers to filter the nodes that need to send messages.

func (*BlockProposeMsg) BroadcastMarkSendRecord

func (bp *BlockProposeMsg) BroadcastMarkSendRecord(ps *peers.PeerSet, peers []string)

BroadcastMarkSendRecord mark send message record to prevent messages from being sent repeatedly.

func (*BlockProposeMsg) GetProposeBlock

func (bp *BlockProposeMsg) GetProposeBlock() (*types.Block, error)

GetProposeBlock get propose block from msg.

func (*BlockProposeMsg) String

func (bp *BlockProposeMsg) String() string

type BlockSignatureMsg

type BlockSignatureMsg struct {
	BlockHash [32]byte
	Signature []byte
	PubKey    []byte
}

BlockSignatureMsg block signature message transferred between nodes.

func (*BlockSignatureMsg) BroadcastFilterTargetPeers

func (bs *BlockSignatureMsg) BroadcastFilterTargetPeers(ps *peers.PeerSet) []string

BroadcastFilterTargetPeers filter target peers to filter the nodes that need to send messages.

func (*BlockSignatureMsg) BroadcastMarkSendRecord

func (bs *BlockSignatureMsg) BroadcastMarkSendRecord(ps *peers.PeerSet, peers []string)

BroadcastMarkSendRecord mark send message record to prevent messages from being sent repeatedly.

func (*BlockSignatureMsg) String

func (bs *BlockSignatureMsg) String() string

type BroadcastMsg

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

BroadcastMsg the message that can be broadcast by peer set.

func NewBroadcastMsg

func NewBroadcastMsg(msg ConsensusMessage, transChan byte) *BroadcastMsg

NewBroadcastMsg create concrete broadcast message, implement peers.BroadcastMsg interface.

func (*BroadcastMsg) FilterTargetPeers

func (b *BroadcastMsg) FilterTargetPeers(ps *peers.PeerSet) []string

FilterTargetPeers filter target peers to filter the nodes that need to send messages.

func (*BroadcastMsg) GetChan

func (b *BroadcastMsg) GetChan() byte

GetChan get message transfer channel.

func (*BroadcastMsg) GetMsg

func (b *BroadcastMsg) GetMsg() interface{}

GetMsg get ConsensusMessage.

func (*BroadcastMsg) MarkSendRecord

func (b *BroadcastMsg) MarkSendRecord(ps *peers.PeerSet, peers []string)

MarkSendRecord mark send message record to prevent messages from being sent repeatedly.

func (*BroadcastMsg) MsgString

func (b *BroadcastMsg) MsgString() string

MsgString get a string representation of the message.

type Chain

type Chain interface {
	BestBlockHeight() uint64
	GetHeaderByHash(*bc.Hash) (*types.BlockHeader, error)
	ProcessBlock(*types.Block) (bool, error)
	ProcessBlockSignature(signature, pubkey []byte, blockHash *bc.Hash) error
}

Chain is the interface for Bytom core.

type ConsensusMessage

type ConsensusMessage interface {
	String() string
	BroadcastMarkSendRecord(ps *peers.PeerSet, peers []string)
	BroadcastFilterTargetPeers(ps *peers.PeerSet) []string
}

ConsensusMessage is a generic message for consensus reactor.

func NewBlockProposeMsg

func NewBlockProposeMsg(block *types.Block) (ConsensusMessage, error)

NewBlockProposeMsg create new block propose msg.

func NewBlockSignatureMsg

func NewBlockSignatureMsg(blockHash bc.Hash, signature, pubKey []byte) ConsensusMessage

NewBlockSignatureMsg create new block signature msg.

type ConsensusReactor

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

ConsensusReactor handles new coming consensus message.

func NewConsensusReactor

func NewConsensusReactor(manager *Manager) *ConsensusReactor

NewConsensusReactor create consensus reactor.

func (*ConsensusReactor) AddPeer

func (cr *ConsensusReactor) AddPeer(peer *p2p.Peer) error

AddPeer implements Reactor by sending our state to peer.

func (*ConsensusReactor) GetChannels

func (cr *ConsensusReactor) GetChannels() []*connection.ChannelDescriptor

GetChannels implements Reactor

func (*ConsensusReactor) OnStart

func (cr *ConsensusReactor) OnStart() error

OnStart implements BaseService

func (*ConsensusReactor) OnStop

func (cr *ConsensusReactor) OnStop()

OnStop implements BaseService

func (*ConsensusReactor) Receive

func (cr *ConsensusReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)

Receive implements Reactor by handling messages.

func (*ConsensusReactor) RemovePeer

func (cr *ConsensusReactor) RemovePeer(peer *p2p.Peer, reason interface{})

RemovePeer implements Reactor by removing peer from the pool.

type Manager

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

Manager is the consensus message network synchronization manager.

func NewManager

func NewManager(sw Switch, chain Chain, peers Peers, dispatcher *event.Dispatcher) *Manager

NewManager create new manager.

func (*Manager) Start

func (m *Manager) Start() error

Start consensus manager service.

func (*Manager) Stop

func (m *Manager) Stop()

Stop consensus manager service.

type Peers added in v1.0.1

type Peers interface {
	AddPeer(peer peers.BasePeer)
	BroadcastMsg(bm peers.BroadcastMsg) error
	GetPeer(id string) *peers.Peer
	MarkBlock(peerID string, hash *bc.Hash)
	MarkBlockSignature(peerID string, signature []byte)
	ProcessIllegal(peerID string, level byte, reason string)
	RemovePeer(peerID string)
	SetStatus(peerID string, height uint64, hash *bc.Hash)
}

type Switch

type Switch interface {
	AddReactor(name string, reactor p2p.Reactor) p2p.Reactor
}

Switch is the interface for p2p switch.

Jump to

Keyboard shortcuts

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