consensusmgr

package
v0.0.0-...-829742f Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2022 License: AGPL-3.0 Imports: 16 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 BlockVerificationMsg

type BlockVerificationMsg struct {
	SourceHash bc.Hash
	TargetHash bc.Hash
	PubKey     []byte
	Signature  []byte
}

BlockVerificationMsg block verification message transferred between nodes.

func (*BlockVerificationMsg) BroadcastFilterTargetPeers

func (b *BlockVerificationMsg) BroadcastFilterTargetPeers(ps *peers.PeerSet) []string

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

func (*BlockVerificationMsg) BroadcastMarkSendRecord

func (b *BlockVerificationMsg) BroadcastMarkSendRecord(ps *peers.PeerSet, peers []string)

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

func (*BlockVerificationMsg) String

func (b *BlockVerificationMsg) 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)
	ProcessBlockVerification(*casper.ValidCasperSignMsg) error
}

Chain is the interface for janeta 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 NewBlockVerificationMsg

func NewBlockVerificationMsg(sourceHash, targetHash bc.Hash, pubKey, signature []byte) ConsensusMessage

NewBlockVerificationMsg create new block verification 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

type Peers interface {
	AddPeer(peer peers.BasePeer)
	BroadcastMsg(bm peers.BroadcastMsg) error
	GetPeer(id string) *peers.Peer
	MarkBlock(peerID string, hash *bc.Hash)
	MarkBlockVerification(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