consensus

package
v0.0.0-...-4a7a8e8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

nolint 20160901 - Initial version by user johnstuartmill, public key 02fb4acf944c84d48341e3c1cb14d707034a68b7f931d6be6d732bec03597d6ff6 20161025 - Code revision by user johnstuartmill.

nolint 20160901 - Initial version by user johnstuartmill, public key 02fb4acf944c84d48341e3c1cb14d707034a68b7f931d6be6d732bec03597d6ff6 20161025 - Code revision by user johnstuartmill.

nolint 20160901 - Initial version by user johnstuartmill, public key 02fb4acf944c84d48341e3c1cb14d707034a68b7f931d6be6d732bec03597d6ff6 20161025 - Code revision by user johnstuartmill.

nolint 20160901 - Initial version by user johnstuartmill, public key 02fb4acf944c84d48341e3c1cb14d707034a68b7f931d6be6d732bec03597d6ff6 20161025 - Code revision by user johnstuartmill.

Index

Constants

This section is empty.

Variables

View Source
var Cfg_blockchain_tail_length int = 100

How many blocks we hold in memory. Older blocks are expected (not implemented yest as of 20160920) to be written to disk.

View Source
var Cfg_consensus_candidate_max_seqno_gap uint64 = 10

To limit memory use and prevent some mild attacks:

View Source
var Cfg_consensus_max_candidate_messages = 10

//////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////// How many (hash,signer_pubkey) pairs to acquire for decision-making. This also limits forwarded traffic, because the messages in excess of this limit are discarded hence not forwarded:

View Source
var Cfg_consensus_waiting_time_as_seqno_diff uint64 = 7

When to decide on selecting the best hash from BlockStat so that it can be moved to BlockChain:

View Source
var Cfg_debug_HashCandidate bool = false
View Source
var Cfg_debug_block_accepted bool = false
View Source
var Cfg_debug_block_duplicate bool = false

//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////

View Source
var Cfg_debug_block_out_of_sequence bool = true

Functions

This section is empty.

Types

type BlockBase

type BlockBase struct {
	Sig   cipher.Sig
	Hash  cipher.SHA256
	Seqno uint64
}

//////////////////////////////////////////////////////////////////////////////

BlockBase

//////////////////////////////////////////////////////////////////////////////

func (*BlockBase) Init

func (self *BlockBase) Init(
	sig cipher.Sig,
	hash cipher.SHA256,
	seqno uint64)

//////////////////////////////////////////////////////////////////////////////

func (*BlockBase) Print

func (self *BlockBase) Print()

//////////////////////////////////////////////////////////////////////////////

func (*BlockBase) String

func (self *BlockBase) String() string

//////////////////////////////////////////////////////////////////////////////

type BlockStat

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

//////////////////////////////////////////////////////////////////////////////

BlockStat

//////////////////////////////////////////////////////////////////////////////

func (*BlockStat) Clear

func (self *BlockStat) Clear()

//////////////////////////////////////////////////////////////////////////////

func (*BlockStat) GetBestHashPubkeySig

func (self *BlockStat) GetBestHashPubkeySig() (
	cipher.SHA256,
	cipher.PubKey,
	cipher.Sig)

//////////////////////////////////////////////////////////////////////////////

func (*BlockStat) GetSeqno

func (self *BlockStat) GetSeqno() uint64

//////////////////////////////////////////////////////////////////////////////

func (*BlockStat) Init

func (self *BlockStat) Init()

//////////////////////////////////////////////////////////////////////////////

func (*BlockStat) Print

func (self *BlockStat) Print()

//////////////////////////////////////////////////////////////////////////////

type BlockStatQueue

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

//////////////////////////////////////////////////////////////////////////////

BlockStatQueue

//////////////////////////////////////////////////////////////////////////////

func (*BlockStatQueue) Len

func (self *BlockStatQueue) Len() int

//////////////////////////////////////////////////////////////////////////////

func (*BlockStatQueue) Print

func (self *BlockStatQueue) Print()

//////////////////////////////////////////////////////////////////////////////

type BlockchainTail

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

//////////////////////////////////////////////////////////////////////////////

BlockchainTail is the most recent part of blockchain that is held in memory

//////////////////////////////////////////////////////////////////////////////

func (*BlockchainTail) GetNextSeqNo

func (self *BlockchainTail) GetNextSeqNo() uint64

//////////////////////////////////////////////////////////////////////////////

func (*BlockchainTail) Init

func (self *BlockchainTail) Init()

//////////////////////////////////////////////////////////////////////////////

func (*BlockchainTail) Print

func (self *BlockchainTail) Print()

//////////////////////////////////////////////////////////////////////////////

type ConnectionManagerInterface

type ConnectionManagerInterface interface {
	SendBlockToAllMySubscriber(blockPtr *BlockBase)

	Print() // For debugging

}

//////////////////////////////////////////////////////////////////////////////

type ConsensusParticipant

type ConsensusParticipant struct {
	Pubkey cipher.PubKey // Who we are
	Seckey cipher.SecKey // For signing

	Incoming_block_count int
	// contains filtered or unexported fields
}

//////////////////////////////////////////////////////////////////////////////

Struct ConsensusParticipant is inteneded to extend (or be contained in) github.com/samoslab/haicoin/src/mesh*/node struct Node, so that Node can participate in consensus.

//////////////////////////////////////////////////////////////////////////////

func NewConsensusParticipantPtr

func NewConsensusParticipantPtr(pMan ConnectionManagerInterface) *ConsensusParticipant

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) GetConnectionManager

func (self *ConsensusParticipant) GetConnectionManager() ConnectionManagerInterface

func (*ConsensusParticipant) GetNextBlockSeqNo

func (self *ConsensusParticipant) GetNextBlockSeqNo() uint64

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) Get_block_stat_queue_Len

func (self *ConsensusParticipant) Get_block_stat_queue_Len() int

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) Get_block_stat_queue_element_at

func (self *ConsensusParticipant) Get_block_stat_queue_element_at(
	j int) *BlockStat

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) OnBlockHeaderArrived

func (self *ConsensusParticipant) OnBlockHeaderArrived(blockPtr *BlockBase)

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) Print

func (self *ConsensusParticipant) Print()

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) SetPubkeySeckey

func (self *ConsensusParticipant) SetPubkeySeckey(
	pubkey cipher.PubKey,
	seckey cipher.SecKey)

//////////////////////////////////////////////////////////////////////////////

func (*ConsensusParticipant) SignatureOf

func (self *ConsensusParticipant) SignatureOf(hash cipher.SHA256) cipher.Sig

////////////////////////////////////////////////////////////////////////////// Reasons for this function: 1st, we want to minimize exposure of SecKey, even in same process space. 2nd, functions Sign and SignHash already exist, so want keep search/browse/jump-to-tag unambiguous.

type HashCandidate

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

//////////////////////////////////////////////////////////////////////////////

HashCandidate

//////////////////////////////////////////////////////////////////////////////

func (*HashCandidate) Clear

func (self *HashCandidate) Clear()

//////////////////////////////////////////////////////////////////////////////

func (*HashCandidate) Init

func (self *HashCandidate) Init()

//////////////////////////////////////////////////////////////////////////////

func (*HashCandidate) ObserveSigAndPubkey

func (self *HashCandidate) ObserveSigAndPubkey(
	sig cipher.Sig,
	pubkey cipher.PubKey)

//////////////////////////////////////////////////////////////////////////////

type PriorityQueue

type PriorityQueue []*BlockStat // Contained in BlockStatQueue

//////////////////////////////////////////////////////////////////////////////

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

NOTE: a shallow copy (of the slice) is made here

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i int, j int) bool

NOTE: a shallow copy (of the slice) is made here

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i int, j int)

NOTE: a shallow copy (of the slice) is made here

Directories

Path Synopsis
nolint

Jump to

Keyboard shortcuts

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