consensus

package
v1.3.18 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const BlsConsensusType = "bls"

BlsConsensusType specifies the signature scheme used in the consensus

Variables

View Source
var (
	ErrInvalidLengthMessage        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMessage          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupMessage = fmt.Errorf("proto: unexpected end of group")
)

Functions

This section is empty.

Types

type BroadcastMessenger

type BroadcastMessenger interface {
	BroadcastBlock(data.BodyHandler, data.HeaderHandler) error
	BroadcastHeader(data.HeaderHandler) error
	BroadcastMiniBlocks(map[uint32][]byte) error
	BroadcastTransactions(map[string][][]byte) error
	BroadcastConsensusMessage(*Message) error
	BroadcastBlockDataLeader(header data.HeaderHandler, miniBlocks map[uint32][]byte, transactions map[string][][]byte) error
	PrepareBroadcastHeaderValidator(header data.HeaderHandler, miniBlocks map[uint32][]byte, transactions map[string][][]byte, order int)
	PrepareBroadcastBlockDataValidator(header data.HeaderHandler, miniBlocks map[uint32][]byte, transactions map[string][][]byte, idx int)
	IsInterfaceNil() bool
}

BroadcastMessenger defines the behaviour of the broadcast messages by the consensus group

type ChronologyHandler

type ChronologyHandler interface {
	Close() error
	AddSubround(SubroundHandler)
	RemoveAllSubrounds()
	// StartRounds starts rounds in a sequential manner, one after the other
	StartRounds()
	IsInterfaceNil() bool
}

ChronologyHandler defines the actions which should be handled by a chronology implementation

type FallbackHeaderValidator added in v1.1.3

type FallbackHeaderValidator interface {
	ShouldApplyFallbackValidation(headerHandler data.HeaderHandler) bool
	IsInterfaceNil() bool
}

FallbackHeaderValidator defines the behaviour of a component able to signal when a fallback header validation could be applied

type HeaderSigVerifier added in v1.1.2

type HeaderSigVerifier interface {
	VerifyRandSeed(header data.HeaderHandler) error
	VerifyLeaderSignature(header data.HeaderHandler) error
	VerifySignature(header data.HeaderHandler) error
	IsInterfaceNil() bool
}

HeaderSigVerifier encapsulates methods that are check if header rand seed, leader signature and aggregate signature are correct

type HeadersPoolSubscriber added in v1.0.106

type HeadersPoolSubscriber interface {
	RegisterHandler(handler func(headerHandler data.HeaderHandler, headerHash []byte))
	IsInterfaceNil() bool
}

HeadersPoolSubscriber can subscribe for notifications when a new block header is added to the headers pool

type InterceptorSubscriber added in v1.0.133

type InterceptorSubscriber interface {
	RegisterHandler(handler func(toShard uint32, data []byte))
	IsInterfaceNil() bool
}

InterceptorSubscriber can subscribe for notifications when data is received by an interceptor

type Message

type Message struct {
	BlockHeaderHash    []byte `protobuf:"bytes,1,opt,name=BlockHeaderHash,proto3" json:"BlockHeaderHash,omitempty"`
	SignatureShare     []byte `protobuf:"bytes,2,opt,name=SignatureShare,proto3" json:"SignatureShare,omitempty"`
	Body               []byte `protobuf:"bytes,3,opt,name=Body,proto3" json:"Body,omitempty"`
	Header             []byte `protobuf:"bytes,4,opt,name=Header,proto3" json:"Header,omitempty"`
	PubKey             []byte `protobuf:"bytes,5,opt,name=PubKey,proto3" json:"PubKey,omitempty"`
	Signature          []byte `protobuf:"bytes,6,opt,name=Signature,proto3" json:"Signature,omitempty"`
	MsgType            int64  `protobuf:"varint,7,opt,name=MsgType,proto3" json:"MsgType,omitempty"`
	RoundIndex         int64  `protobuf:"varint,8,opt,name=RoundIndex,proto3" json:"RoundIndex,omitempty"`
	ChainID            []byte `protobuf:"bytes,9,opt,name=ChainID,proto3" json:"ChainID,omitempty"`
	PubKeysBitmap      []byte `protobuf:"bytes,10,opt,name=PubKeysBitmap,proto3" json:"PubKeysBitmap,omitempty"`
	AggregateSignature []byte `protobuf:"bytes,11,opt,name=AggregateSignature,proto3" json:"AggregateSignature,omitempty"`
	LeaderSignature    []byte `protobuf:"bytes,12,opt,name=LeaderSignature,proto3" json:"LeaderSignature,omitempty"`
	OriginatorPid      []byte `protobuf:"bytes,13,opt,name=OriginatorPid,proto3" json:"OriginatorPid,omitempty"`
}

Message defines the data needed by spos to communicate between nodes over network in all subrounds

func NewConsensusMessage

func NewConsensusMessage(
	blHeaderHash []byte,
	signatureShare []byte,
	body []byte,
	header []byte,
	pubKey []byte,
	sig []byte,
	msg int,
	roundIndex int64,
	chainID []byte,
	pubKeysBitmap []byte,
	aggregateSignature []byte,
	leaderSignature []byte,
	currentPid core.PeerID,
) *Message

NewConsensusMessage creates a new Message object

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) Equal

func (this *Message) Equal(that interface{}) bool

func (*Message) GetAggregateSignature

func (m *Message) GetAggregateSignature() []byte

func (*Message) GetBlockHeaderHash

func (m *Message) GetBlockHeaderHash() []byte

func (*Message) GetBody

func (m *Message) GetBody() []byte

func (*Message) GetChainID

func (m *Message) GetChainID() []byte

func (*Message) GetHeader

func (m *Message) GetHeader() []byte

func (*Message) GetLeaderSignature

func (m *Message) GetLeaderSignature() []byte

func (*Message) GetMsgType

func (m *Message) GetMsgType() int64

func (*Message) GetOriginatorPid added in v1.0.133

func (m *Message) GetOriginatorPid() []byte

func (*Message) GetPubKey

func (m *Message) GetPubKey() []byte

func (*Message) GetPubKeysBitmap

func (m *Message) GetPubKeysBitmap() []byte

func (*Message) GetRoundIndex

func (m *Message) GetRoundIndex() int64

func (*Message) GetSignature

func (m *Message) GetSignature() []byte

func (*Message) GetSignatureShare

func (m *Message) GetSignatureShare() []byte

func (*Message) GoString

func (this *Message) GoString() string

func (*Message) Marshal

func (m *Message) Marshal() (dAtA []byte, err error)

func (*Message) MarshalTo

func (m *Message) MarshalTo(dAtA []byte) (int, error)

func (*Message) MarshalToSizedBuffer

func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) Size

func (m *Message) Size() (n int)

func (*Message) String

func (this *Message) String() string

func (*Message) Unmarshal

func (m *Message) Unmarshal(dAtA []byte) error

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

type MessageType

type MessageType int

MessageType specifies what type of message was received

type NetworkShardingCollector

type NetworkShardingCollector interface {
	UpdatePeerIDInfo(pid core.PeerID, pk []byte, shardID uint32)
	UpdatePeerIdSubType(pid core.PeerID, peerSubType core.P2PPeerSubType)
	GetPeerInfo(pid core.PeerID) core.P2PPeerInfo
	IsInterfaceNil() bool
}

NetworkShardingCollector defines the updating methods used by the network sharding component The interface assures that the collected data will be used by the p2p network sharding components

type NodeRedundancyHandler added in v1.1.31

type NodeRedundancyHandler interface {
	IsRedundancyNode() bool
	IsMainMachineActive() bool
	AdjustInactivityIfNeeded(selfPubKey string, consensusPubKeys []string, roundIndex int64)
	ResetInactivityIfNeeded(selfPubKey string, consensusMsgPubKey string, consensusMsgPeerID core.PeerID)
	ObserverPrivateKey() crypto.PrivateKey
	IsInterfaceNil() bool
}

NodeRedundancyHandler provides functionality to handle the redundancy mechanism for a node

type P2PAntifloodHandler

type P2PAntifloodHandler interface {
	CanProcessMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error
	CanProcessMessagesOnTopic(peer core.PeerID, topic string, numMessages uint32, totalSize uint64, sequence []byte) error
	ResetForTopic(topic string)
	SetMaxMessagesForTopic(topic string, maxNum uint32)
	BlacklistPeer(peer core.PeerID, reason string, duration time.Duration)
	IsInterfaceNil() bool
}

P2PAntifloodHandler defines the behavior of a component able to signal that the system is too busy (or flooded) processing p2p messages

type P2PMessenger

type P2PMessenger interface {
	Broadcast(topic string, buff []byte)
	IsInterfaceNil() bool
}

P2PMessenger defines a subset of the p2p.Messenger interface

type PeerHonestyHandler added in v1.0.133

type PeerHonestyHandler interface {
	ChangeScore(pk string, topic string, units int)
	IsInterfaceNil() bool
	Close() error
}

PeerHonestyHandler defines the behaivour of a component able to handle/monitor the peer honesty of nodes which are participating in consensus

type RoundHandler added in v1.2.0

type RoundHandler interface {
	Index() int64
	BeforeGenesis() bool
	// UpdateRound updates the index and the time stamp of the round depending of the genesis time and the current time given
	UpdateRound(time.Time, time.Time)
	TimeStamp() time.Time
	TimeDuration() time.Duration
	RemainingTime(startTime time.Time, maxTime time.Duration) time.Duration
	IsInterfaceNil() bool
}

RoundHandler defines the actions which should be handled by a round implementation

type ScheduledProcessor added in v1.3.0

type ScheduledProcessor interface {
	StartScheduledProcessing(header data.HeaderHandler, body data.BodyHandler, startTime time.Time)
	ForceStopScheduledExecutionBlocking()
	IsProcessedOKWithTimeout() bool
	IsInterfaceNil() bool
}

ScheduledProcessor encapsulates the scheduled processor functionality required by consensus module

type SubroundHandler

type SubroundHandler interface {
	// DoWork implements of the subround's job
	DoWork(ctx context.Context, roundHandler RoundHandler) bool
	// Previous returns the ID of the previous subround
	Previous() int
	// Next returns the ID of the next subround
	Next() int
	// Current returns the ID of the current subround
	Current() int
	// StartTime returns the start time, in the roundHandler time, of the current subround
	StartTime() int64
	// EndTime returns the top limit time, in the roundHandler time, of the current subround
	EndTime() int64
	// Name returns the name of the current roundHandler
	Name() string
	// ConsensusChannel returns the consensus channel
	ConsensusChannel() chan bool
	// IsInterfaceNil returns true if there is no value under the interface
	IsInterfaceNil() bool
}

SubroundHandler defines the actions which should be handled by a subround implementation

Directories

Path Synopsis
bls

Jump to

Keyboard shortcuts

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