state

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 55 Imported by: 78

Documentation

Overview

Defines the state for factoid. By using the proper interfaces, the functionality of factoid can be imported into any framework.

Index

Constants

View Source
const BATCH_SIZE uint32 = 250

BATCH_SIZE is the amount of blocks per torrent

View Source
const Range = 60 // Double this for the period we protect, i.e. 120 means +/- 120 minutes

Variables

View Source
var (
	// EntrySyncMax is the maximum amount of entries to request concurrently
	EntrySyncMax = 750 // good-ish value
	// EntrySyncMaxEBlocks is the maximum amount of eblocks to process concurrently.
	// The value only applies if that range of eblocks has fewer than EntrySyncMax entries.
	EntrySyncMaxEBlocks = 200
	// EntrySyncRetry dictates after what period to retry an unanswered request
	EntrySyncRetry = time.Second * 10
	// EntrySyncWarning is the number of failed requests before warning in the console.
	EntrySyncWarning = 16
)
View Source
var (
	// Time window for identity to require registration: 24hours = 144 blocks
	TIME_WINDOW uint32 = 144

	// Where all Identities register
	MAIN_FACTOM_IDENTITY_LIST = "888888001750ede0eff4b05f0c3f557890b256450cabbb84cada937f9c258327"
)
View Source
var (

	// Entry Syncing Controller
	ESMissingQueue = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_missing_entry_queue",
		Help: "Number of known missing entries in our queue to find.",
	})
	ESMissing = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_missing_entries",
		Help: "Number of known missing entries",
	})
	ESFound = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_found_entries",
		Help: "Number of known missing entries found.",
	})
	ESAsking = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_asking_missing_entries",
		Help: "Number we are asking for of the known missing entries.",
	})
	ESHighestAsking = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_highest_asking_entries",
		Help: "Highest entry DBHeight which has has a request made.",
	})
	ESHighestMissing = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_highest_missing_entries",
		Help: "Highest DBHeight of the entries we know are missing.",
	})
	ESFirstMissing = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_first_missing_entries",
		Help: "First DBHeight with a missing entry",
	})
	ESDBHTComplete = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_entry_dbheight_complete",
		Help: "First DBHeight with a missing entry",
	})
	ESAvgRequests = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_es_average_requests",
		Help: "Average number of times we have had to request a missing entry",
	})
	HighestAck = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_highest_ack",
		Help: "Acknowledgement with the highest directory block height",
	})
	HighestKnown = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_highest_known",
		Help: "Highest known block (which can be different than the highest ack)",
	})
	HighestSaved = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_highest_saved",
		Help: "Highest saved block to the database",
	})
	HighestCompleted = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_highest_completed",
		Help: "Highest completed block, which may or may not be saved to the database",
	})

	// TPS
	TotalTransactionPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_txrate_total_tps",
		Help: "Total transactions over life of node",
	})

	InstantTransactionPerSecond = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_txrate_instant_tps",
		Help: "Total transactions over life of node weighted for last 3 seconds",
	})

	// Queues
	CurrentMessageQueueInMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_queue_current_general_inmsg_vec",
		Help: "Instrumenting the current  inmsg queue ",
	}, []string{"message"})

	TotalMessageQueueInMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_queue_total_general_inmsg_vec",
		Help: "Instrumenting the inmsg queue ",
	}, []string{"message"})

	CurrentMessageQueueApiGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_queue_current_general_api_vec",
		Help: "Instrumenting the current API queue ",
	}, []string{"message"})

	TotalMessageQueueApiGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_queue_total_general_api_vec",
		Help: "Instrumenting the API queue ",
	}, []string{"message"})

	TotalMessageQueueNetOutMsgGeneralVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_queue_total_general_netoutmsg_vec",
		Help: "Instrumenting the netoutmsg queue ",
	}, []string{"message"})

	// MsgQueue chan
	TotalMsgQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_msgqueue_total_inputs",
		Help: "Tally of total messages gone into MsgQueue (useful for rating)",
	})
	TotalMsgQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_msgqueue_total_outputs",
		Help: "Tally of total messages drained out of MsgQueue (useful for rating)",
	})

	// Holding Queue
	TotalHoldingQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_total_inputs",
		Help: "Tally of total messages gone into Holding (useful for rating)",
	})
	TotalHoldingQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_total_outputs",
		Help: "Tally of total messages drained out of Holding (useful for rating)",
	})
	TotalHoldingQueueRecycles = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_total_recycles",
		Help: "Tally of total messages recycled thru Holding (useful for rating)",
	})
	HoldingQueueDBSigInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_dbsig_inputs",
		Help: "Tally of DBSig messages gone into Holding (useful for rating)",
	})
	HoldingQueueDBSigOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_dbsig_outputs",
		Help: "Tally of DBSig messages drained out of Holding",
	})
	HoldingQueueCommitEntryInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_commitentry_inputs",
		Help: "Tally of CommitEntry messages gone into Holding (useful for rating)",
	})
	HoldingQueueCommitEntryOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_commitentry_outputs",
		Help: "Tally of CommitEntry messages drained out of Holding",
	})
	HoldingQueueCommitChainInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_commitchain_inputs",
		Help: "Tally of CommitChain messages gone into Holding (useful for rating)",
	})
	HoldingQueueCommitChainOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_commitchain_outputs",
		Help: "Tally of CommitChain messages drained out of Holding",
	})
	HoldingQueueRevealEntryInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_revealentry_inputs",
		Help: "Tally of RevealEntry messages gone into Holding (useful for rating)",
	})
	HoldingQueueRevealEntryOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_holding_queue_revealentry_outputs",
		Help: "Tally of RevealEntry messages drained out of Holding",
	})

	// Acks Queue
	TotalAcksInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_acks_total_inputs",
		Help: "Tally of total messages gone into Acks (useful for rating)",
	})
	TotalAcksOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_acks_total_outputs",
		Help: "Tally of total messages drained out of Acks (useful for rating)",
	})

	// Commits map
	TotalCommitsInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_commits_total_inputs",
		Help: "Tally of total messages gone into Commits (useful for rating)",
	})
	TotalCommitsOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_commits_total_outputs",
		Help: "Tally of total messages drained out of Commits (useful for rating)",
	})

	// XReview Queue
	TotalXReviewQueueInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_xreview_queue_total_inputs",
		Help: "Tally of total messages gone into XReview (useful for rating)",
	})
	TotalXReviewQueueOutputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_xreview_queue_total_outputs",
		Help: "Tally of total messages drained out of XReview (useful for rating)",
	})

	// Executions
	LeaderExecutions = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_leader_executions",
		Help: "Tally of total messages executed via LeaderExecute",
	})
	FollowerExecutions = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_follower_executions",
		Help: "Tally of total messages executed via FollowerExecute",
	})
	LeaderEOMExecutions = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_leader_eom_executions",
		Help: "Tally of total messages executed via LeaderExecuteEOM",
	})
	FollowerEOMExecutions = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_follower_eom_executions",
		Help: "Tally of total messages executed via FollowerExecuteEOM",
	})
	FollowerMissingMsgExecutions = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_follower_mm_executions",
		Help: "Tally of total messages executed via FollowerExecuteMissingMsg",
	})

	// ProcessList
	TotalProcessListInputs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_process_list_inputs",
		Help: "Tally of total messages gone into ProcessLists (useful for rating)",
	})
	TotalProcessListProcesses = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_process_list_processes",
		Help: "Tally of total messages processed from ProcessLists (useful for rating)",
	})
	TotalProcessEOMs = prometheus.NewCounter(prometheus.CounterOpts{
		Name: "factomd_state_process_eom_processes",
		Help: "Tally of EOM messages processed from ProcessLists (useful for rating)",
	})

	// Durations
	TotalReviewHoldingTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_review_holding_time",
		Help: "Time spent in ReviewHolding()",
	})
	TotalProcessXReviewTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_process_xreview_time",
		Help: "Time spent Processing XReview",
	})
	TotalProcessProcChanTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_process_proc_chan_time",
		Help: "Time spent Processing Process Chan",
	})
	TotalEmptyLoopTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_empty_loop_time",
		Help: "Time spent in empty loop",
	})
	TotalAckLoopTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_ack_loop_time",
		Help: "Time spent in ack loop",
	})
	TotalExecuteMsgTime = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "factomd_state_execute_msg_time",
		Help: "Time spent in executeMsg",
	})

	//		Eom/DBSig delay
	LeaderSyncAckDelay = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_consensus_sync_delay_ack_vec_sec",
		Help: "Instruments the delay in the time an ack (eom/dbsig only) was signed by a leader, " +
			"and the time it took our node to receive it in nanoseconds.",
	}, []string{"leader"})

	LeaderSyncMsgDelay = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_consensus_sync_delay_msg_vec_sec",
		Help: "Instruments the delay in the time a msg (eom/dbsig only) was signed by a leader, " +
			"and the time it took our node to receive it in nanoseconds.",
	}, []string{"leader"})

	LeaderSyncAckPairDelay = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "factomd_state_consensus_ackpair_delay_vec_sec",
		Help: "Instruments the delay in the time an ack & msg pair was received. " +
			"If there is a delay, it means the ack+msg would benefit from being " +
			"coupled. The delay is measured in seconds.",
	}, []string{"leader"})
)
View Source
var ControlPanelAllowedSize int = 2
View Source
var FilterTimeLimit = int64(Range * 60 * 2 * 1000000000) // Filter hold two hours of messages, one in the past one in the future
View Source
var MMR_enable bool = true

Used by debug code only

View Source
var ValidationDebug bool = false

Functions

func AppendExtIDs

func AppendExtIDs(extIDs [][]byte, start int, end int) ([]byte, error)

func BytesToUint32

func BytesToUint32(data []byte) (ret uint32, err error)

func CheckDBKeyMR

func CheckDBKeyMR(s *State, ht uint32, hash string) error

*************************************************************** Checkpoint DBKeyMR ***************************************************************

func CheckGrants

func CheckGrants()

func CheckLength

func CheckLength(length int, item []byte) bool

func CheckSig

func CheckSig(idKey interfaces.IHash, pub []byte, msg []byte, sig []byte) bool

Sig is signed message, msg is raw message

func DeleteFile

func DeleteFile(filename string) error

func FaultCheck

func FaultCheck(pl *ProcessList)

func FedServerVM

func FedServerVM(serverMap [10][64]int, numberOfFedServers int, minute int, fedIndex int) int

func GetGrantPayoutsFor

func GetGrantPayoutsFor(currentDBHeight uint32) []interfaces.ITransAddress

return a (possibly empty) of coinbase payouts to be scheduled at this height

func GetMapHash

func GetMapHash(bmap map[[32]byte]int64) interfaces.IHash

func HeightToHash

func HeightToHash(height uint32, minute int) [32]byte

put a height in the first 5 bytes of a hash so we can use it to look up dependent message in holding

func LoadDatabase

func LoadDatabase(s *State)

func LoadFromFile

func LoadFromFile(s *State, filename string) ([]byte, error)

func MakeMap

func MakeMap(numberFedServers int, dbheight uint32) (serverMap [10][64]int)

This function will be replaced by a calculation from the Matryoshka hashes from the servers but for now, we are just going to make it a function of the dbheight. serverMap[minute][vmIndex] => Index of the Federated Server responsible for that minute

func Minutes

func Minutes(unix int64) int

Remember that Unix time is in seconds since 1970. This code wants to be handed time in seconds.

func NetworkIDToFilename

func NetworkIDToFilename(networkName string, fileLocation string) string

func NonBlockingChannelAdd

func NonBlockingChannelAdd(channel chan interfaces.IMsg, msg interfaces.IMsg) bool

NonBlockingChannelAdd will only add to the channel if the action is non-blocking

func PopBalanceMap

func PopBalanceMap(buf *primitives.Buffer) (map[[32]byte]int64, error)

func PopBucketMap

func PopBucketMap(buf *primitives.Buffer) (map[[32]byte]int, error)

func PrintState

func PrintState(state *State)

func ProcessIdentityToAdminBlock

func ProcessIdentityToAdminBlock(st *State, chainID interfaces.IHash, servertype int) bool

Called by AddServer Message

func PushBalanceMap

func PushBalanceMap(b *primitives.Buffer, m map[[32]byte]int64) error

func PushBucketMap

func PushBucketMap(b *primitives.Buffer, m map[[32]byte]int) error

func RandomServer

func RandomServer() interfaces.IServer

func RegisterPrometheus

func RegisterPrometheus()

RegisterPrometheus registers the variables to be exposed. This can only be run once, hence the boolean flag to prevent panics if launched more than once. This is called in NetStart

func SaveToFile

func SaveToFile(s *State, dbht uint32, b []byte, filename string) error

func SortServers

func SortServers(servers []interfaces.IServer) []interfaces.IServer

func Uint32ToBytes

func Uint32ToBytes(val uint32) ([]byte, error)

Types

type ACKMap

type ACKMap struct {
	Acks     map[MsgHeight]interfaces.IMsg
	MsgOrder [1000]MsgHeight
	N        int
}

map of the last N Acks indexed by height

func (*ACKMap) Add

func (a *ACKMap) Add(msg interfaces.IMsg)

Adds Acks to a map of the last 1000 acks The map of acks will be used in tandem with the message map when we get an MMR to ensure we don't ask for a message we already have.

func (*ACKMap) Get

func (a *ACKMap) Get(DBHeight int, vmIndex int, height int) interfaces.IMsg

type APIMSGQueue

type APIMSGQueue chan interfaces.IMsg

APIMSGQueue counts incoming and outgoing messages for API queue

func NewAPIQueue

func NewAPIQueue(capacity int) APIMSGQueue

func (APIMSGQueue) BlockingDequeue

func (q APIMSGQueue) BlockingDequeue() interfaces.IMsg

BlockingDequeue will block until it retrieves from queue

func (APIMSGQueue) Cap

func (q APIMSGQueue) Cap() int

Cap of underlying channel

func (APIMSGQueue) Dequeue

func (q APIMSGQueue) Dequeue() interfaces.IMsg

Dequeue removes an item from channel and instruments based on type. Returns nil if nothing in queue

func (APIMSGQueue) Enqueue

func (q APIMSGQueue) Enqueue(m interfaces.IMsg)

Enqueue adds item to channel and instruments based on type

func (APIMSGQueue) Length

func (q APIMSGQueue) Length() int

Length of underlying channel

type AckMsgPairCache

type AckMsgPairCache struct {
	CurrentWorkingHeight int
	// MsgPairMap will contain ack/msg pairs
	MsgPairMap map[int]map[plRef]*MsgPair
}

func NewAckMsgCache

func NewAckMsgCache() *AckMsgPairCache

func (*AckMsgPairCache) AddMsgPair

func (a *AckMsgPairCache) AddMsgPair(pair *MsgPair)

AddMsgPair will add an ack to the cache if it is not too old, and it is an ack+msg pair

We assume that all msgs being added have been added to our processlist, and therefore
the current working height and they are valid.

func (*AckMsgPairCache) Expire

func (a *AckMsgPairCache) Expire(newHeight int)

Expire for the AckMsgPairCache will expire all acks older than 2 blocks.

TODO: Is iterating over a map extra cost? Should we have a sorted list?
		Technically we can just call delete NewHeight-2 as long as we always
		Update every height

func (*AckMsgPairCache) Get

func (a *AckMsgPairCache) Get(dbHeight, vmIndex, plHeight int) *MsgPair

func (*AckMsgPairCache) HeightTooOld

func (a *AckMsgPairCache) HeightTooOld(height int) bool

HeightTooOld determines if the ack height is too old for the ackcache

func (*AckMsgPairCache) UpdateWorkingHeight

func (a *AckMsgPairCache) UpdateWorkingHeight(newHeight int)

UpdateWorkingHeight will only update the height if it is new

type ByKey

type ByKey [][32]byte

func (ByKey) Len

func (f ByKey) Len() int

func (ByKey) Less

func (f ByKey) Less(i, j int) bool

func (ByKey) Swap

func (f ByKey) Swap(i, j int)

type CrossReplayFilter

type CrossReplayFilter struct {
	Currentheight int
	LowestHeight  int
	// contains filtered or unexported fields
}

CrossReplayFilter checks for old messages across reboots based on the salts inside the ack messages. It saves all salts of leaders it sees while running. On reboot, it will ignore all messages that have an old salt (for a set duration). After the duration, no new salts are saved (extra overhead we don't need) and will stop ignoring messages based on salts (so a single leader reboot will rejoin the network).

func NewCrossReplayFilter

func NewCrossReplayFilter(path string) *CrossReplayFilter

func (*CrossReplayFilter) AddSalt

func (c *CrossReplayFilter) AddSalt(height uint32, salt [8]byte) error

AddSalt will add the salt to the replay filter that is used on reboot

func (*CrossReplayFilter) Close

func (c *CrossReplayFilter) Close()

func (*CrossReplayFilter) ExistOldSalt

func (c *CrossReplayFilter) ExistOldSalt(salt [8]byte) bool

ExistOldSalt checks to see if the salt existed on the previous boot

func (*CrossReplayFilter) ExistSalt

func (c *CrossReplayFilter) ExistSalt(salt [8]byte) (bool, error)

Exists check if the hash is in the replay filter, and if it encounters a db error, it will report false

func (*CrossReplayFilter) Run

func (c *CrossReplayFilter) Run()

Run is a simple loop that ensures we discard old data we do not need.

type DBSig

type DBSig struct {
	ChainID   interfaces.IHash
	Signature interfaces.IFullSignature
	VMIndex   int
}

Data needed to add to admin block

type DBState

type DBState struct {
	IsNew bool

	SaveStruct *SaveState

	DBHash interfaces.IHash
	ABHash interfaces.IHash
	FBHash interfaces.IHash
	ECHash interfaces.IHash

	DirectoryBlock   interfaces.IDirectoryBlock
	AdminBlock       interfaces.IAdminBlock
	FactoidBlock     interfaces.IFBlock
	EntryCreditBlock interfaces.IEntryCreditBlock

	EntryBlocks []interfaces.IEntryBlock
	Entries     []interfaces.IEBEntry

	Repeat      bool
	ReadyToSave bool
	Locked      bool
	Signed      bool
	Saved       bool

	Added interfaces.Timestamp

	FinalExchangeRate uint64
	NextTimestamp     interfaces.Timestamp
}

func (*DBState) GetAdminBlock

func (dbs *DBState) GetAdminBlock() interfaces.IAdminBlock

func (*DBState) GetDirectoryBlock

func (dbs *DBState) GetDirectoryBlock() interfaces.IDirectoryBlock

func (*DBState) GetEntries

func (dbs *DBState) GetEntries() []interfaces.IEBEntry

func (*DBState) GetEntryBlocks

func (dbs *DBState) GetEntryBlocks() []interfaces.IEntryBlock

func (*DBState) GetEntryCreditBlock

func (dbs *DBState) GetEntryCreditBlock() interfaces.IEntryCreditBlock

func (*DBState) GetFactoidBlock

func (dbs *DBState) GetFactoidBlock() interfaces.IFBlock

func (*DBState) Init

func (dbs *DBState) Init()

func (*DBState) IsSameAs

func (a *DBState) IsSameAs(b *DBState) bool

func (*DBState) MarshalBinary

func (dbs *DBState) MarshalBinary() (rval []byte, err error)

func (*DBState) String

func (ds *DBState) String() string

func (*DBState) UnmarshalBinary

func (dbs *DBState) UnmarshalBinary(p []byte) error

func (*DBState) UnmarshalBinaryData

func (dbs *DBState) UnmarshalBinaryData(p []byte) (newData []byte, err error)

func (*DBState) ValidNext

func (d *DBState) ValidNext(state *State, next *messages.DBStateMsg) int

Validate this directory block given the next Directory Block. Need to check the signatures as being from the authority set, and valid. Also check that this DBState holds a previous KeyMR that matches the previous DBState KeyMR.

Return a -1 on failure.

type DBStateList

type DBStateList struct {
	LastEnd       int
	LastBegin     int
	TimeToAsk     interfaces.Timestamp
	ProcessHeight uint32
	SavedHeight   uint32
	State         *State
	Base          uint32
	Complete      uint32
	DBStates      []*DBState
}

func (*DBStateList) Catchup

func (list *DBStateList) Catchup()

TODO: Redesign Catchup. Some assumptions were made that made this more TODO: complex than it needed to be.

func (list *DBStateList) FixupLinks(p *DBState, d *DBState) (progress bool)

p is previous, d is current

func (*DBStateList) Get

func (list *DBStateList) Get(height int) *DBState

func (*DBStateList) GetHighestCompletedBlk

func (list *DBStateList) GetHighestCompletedBlk() uint32

func (*DBStateList) GetHighestLockedSignedAndSavesBlk

func (list *DBStateList) GetHighestLockedSignedAndSavesBlk() uint32

func (*DBStateList) GetHighestSavedBlk

func (list *DBStateList) GetHighestSavedBlk() uint32

func (*DBStateList) GetHighestSignedBlk

func (list *DBStateList) GetHighestSignedBlk() uint32

func (*DBStateList) Highest

func (list *DBStateList) Highest() uint32

func (*DBStateList) Init

func (dbsl *DBStateList) Init()

func (*DBStateList) IsSameAs

func (a *DBStateList) IsSameAs(b *DBStateList) bool

func (*DBStateList) Last

func (list *DBStateList) Last() *DBState

func (*DBStateList) MarshalBinary

func (dbsl *DBStateList) MarshalBinary() (rval []byte, err error)

func (*DBStateList) NewDBState

func (list *DBStateList) NewDBState(isNew bool,
	directoryBlock interfaces.IDirectoryBlock,
	adminBlock interfaces.IAdminBlock,
	factoidBlock interfaces.IFBlock,
	entryCreditBlock interfaces.IEntryCreditBlock,
	eBlocks []interfaces.IEntryBlock,
	entries []interfaces.IEBEntry) *DBState

func (*DBStateList) ProcessBlocks

func (list *DBStateList) ProcessBlocks(d *DBState) (progress bool)

func (*DBStateList) Put

func (list *DBStateList) Put(dbState *DBState) bool

Return true if we actually added the dbstate to the list

func (*DBStateList) SaveDBStateToDB

func (list *DBStateList) SaveDBStateToDB(d *DBState) (progress bool)

func (*DBStateList) SignDB

func (list *DBStateList) SignDB(d *DBState) (process bool)

We don't really do the signing here, but just check that we have all the signatures. If we do, we count that as progress.

func (*DBStateList) String

func (list *DBStateList) String() string

func (*DBStateList) UnmarshalBinary

func (dbsl *DBStateList) UnmarshalBinary(p []byte) error

func (*DBStateList) UnmarshalBinaryData

func (dbsl *DBStateList) UnmarshalBinaryData(p []byte) (newData []byte, err error)

func (*DBStateList) UpdateState

func (list *DBStateList) UpdateState() (progress bool)

func (*DBStateList) WriteDBStateToDebugFile

func (list *DBStateList) WriteDBStateToDebugFile(d *DBState)

WriteDBStateToDebugFile will write the marshaled dbstate to a file alongside the database. This can be written on the processblocks, so in the event the block does not get written to disk in the event of a stall, the dbstate can be analyzed. The written dbstate does NOT include entries.

type DisplayState

type DisplayState struct {
	NodeName string

	ControlPanelPort    int
	ControlPanelSetting int

	// DB Info
	CurrentNodeHeight   uint32
	CurrentLeaderHeight uint32
	CurrentEBDBHeight   uint32
	LeaderHeight        uint32
	LastDirectoryBlock  interfaces.IDirectoryBlock

	// Identity Info
	IdentityChainID interfaces.IHash
	Identities      []*Identity
	Authorities     []*Authority
	PublicKey       *primitives.PublicKey

	// Process List
	PLFactoid []FactoidTransaction
	PLEntry   []EntryTransaction

	// DataDump
	RawSummary          string
	PrintMap            string
	ProcessList0        string
	ProcessList         string
	ProcessList2        string
	Election            string
	SimElection         string
	SyncingState        [256]string
	SyncingStateCurrent int
	IgnoreDone          bool
}

This struct will contain all information wanted by the control panel from the state.

func DeepStateDisplayCopy

func DeepStateDisplayCopy(s *State) (*DisplayState, error)

func DeepStateDisplayCopyDifference

func DeepStateDisplayCopyDifference(s *State, prev *DisplayState) (*DisplayState, error)

func NewDisplayState

func NewDisplayState() *DisplayState

func (*DisplayState) Clone

func (d *DisplayState) Clone() *DisplayState

Used for display dump. Allows a clone of the display state to be made

func (*DisplayState) CopyDirectoryBlock

func (ds *DisplayState) CopyDirectoryBlock(s *State, prev *DisplayState, height uint32)

type ElectionQueue

type ElectionQueue chan interfaces.IMsg

ElectionQueue counts incoming and outgoing messages for inmsg queue

func NewElectionQueue

func NewElectionQueue(capacity int) ElectionQueue

func (ElectionQueue) BlockingDequeue

func (q ElectionQueue) BlockingDequeue() interfaces.IMsg

BlockingDequeue will block until it retrieves from queue

func (ElectionQueue) Cap

func (q ElectionQueue) Cap() int

Cap of underlying channel

func (ElectionQueue) Dequeue

func (q ElectionQueue) Dequeue() interfaces.IMsg

Dequeue removes an item from channel and instruments based on type. Returns nil if nothing in queue

func (ElectionQueue) Enqueue

func (q ElectionQueue) Enqueue(m interfaces.IMsg)

Enqueue adds item to channel and instruments based on type

func (ElectionQueue) Length

func (q ElectionQueue) Length() int

Length of underlying channel

type EntrySync

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

EntrySync is responsible for sending the requests to fetch missing entries to the network. (aka 2nd pass sync) The general algorithms are as follows:

Sync: Start with the last known complete height 1. Load the DBlock and iterate over all EBlock hashes 2. For each EBlock, iterate over the Entry hashes 3. If the DB has the entry, skip, otherwise add the hash to the ask queue 4. Collate all missing entry hashes for each EBlock and add it to eblock queue 5. Inform state we are processing up to that eblock

Ask: 1. Look at the first N records of the ask queue 2. If the entry exists, remove it from queue 3. If it's the first time or time threshold passed, send a request to the network

Check: 1. Look at the first record of the eblock queue 2. Go through all missing records and check if they exist 3. If there are still missing records, wait and go back to 1 4. If the eblock is finished, inform the state we have all the entries up to that eblock

func NewEntrySync

func NewEntrySync(s *State) *EntrySync

NewEntrySync creates a new EntrySync

func (*EntrySync) AskedFor

func (es *EntrySync) AskedFor(hash interfaces.IHash) bool

AskedFor returns true if the entry sync routine asked for a specific hash and that entry has not yet been found in the database. Returns false otherwise.

func (*EntrySync) DelayedStart

func (es *EntrySync) DelayedStart()

DelayedStart waits for the database to be finished loading before starting the syncing process

func (*EntrySync) Position

func (es *EntrySync) Position() uint32

Positions returns the DBlock EntrySync is adding next

func (*EntrySync) Stop

func (es *EntrySync) Stop()

Stop initiates shutdown and will stop all associated goroutines

func (*EntrySync) SyncHeight

func (es *EntrySync) SyncHeight()

SyncHeight starts the Sync, Ask, and Check routines.

type EntryTransaction

type EntryTransaction struct {
	ChainID   string
	EntryHash string
}

type EntryUpdate

type EntryUpdate struct {
	Hash      interfaces.IHash
	Timestamp interfaces.Timestamp
}

type FactoidState

type FactoidState struct {
	DBHeight     uint32
	State        *State
	CurrentBlock interfaces.IFBlock
	Wallet       interfaces.ISCWallet
}

func (*FactoidState) AddECBlock

func (fs *FactoidState) AddECBlock(blk interfaces.IEntryCreditBlock) error

func (*FactoidState) AddTransaction

func (fs *FactoidState) AddTransaction(index int, trans interfaces.ITransaction) error

Only add valid transactions to the current

func (*FactoidState) AddTransactionBlock

func (fs *FactoidState) AddTransactionBlock(blk interfaces.IFBlock) error

When we are playing catchup, adding the transaction block is a pretty useful feature.

func (*FactoidState) EndOfPeriod

func (fs *FactoidState) EndOfPeriod(period int)

func (*FactoidState) GetBalanceHash

func (fs *FactoidState) GetBalanceHash(TempBalanceHash bool) (rval interfaces.IHash)

GetBalanceHash() Compute either a Hash of the temporary balance hash map, or the Permanent Balance hash map

func (*FactoidState) GetCoinbaseTransaction

func (fs *FactoidState) GetCoinbaseTransaction(dbheight uint32, ftime interfaces.Timestamp) interfaces.ITransaction

func (*FactoidState) GetCurrentBlock

func (fs *FactoidState) GetCurrentBlock() interfaces.IFBlock

func (*FactoidState) GetECBalance

func (fs *FactoidState) GetECBalance(address [32]byte) int64

func (*FactoidState) GetFactoidBalance

func (fs *FactoidState) GetFactoidBalance(address [32]byte) int64

func (*FactoidState) GetMultipleECBalances

func (fs *FactoidState) GetMultipleECBalances(singleAdd [32]byte) (uint32, uint32, int64, int64, string)

func (*FactoidState) GetMultipleFactoidBalances

func (fs *FactoidState) GetMultipleFactoidBalances(singleAdd [32]byte) (uint32, uint32, int64, int64, string)

func (*FactoidState) ProcessEndOfBlock

func (fs *FactoidState) ProcessEndOfBlock(state interfaces.IState)

End of Block means packing the current block away, and setting up the next

func (*FactoidState) UpdateECTransaction

func (fs *FactoidState) UpdateECTransaction(rt bool, trans interfaces.IECBlockEntry) error

func (*FactoidState) UpdateTransaction

func (fs *FactoidState) UpdateTransaction(rt bool, trans interfaces.ITransaction) error

Assumes validation has already been done.

func (*FactoidState) Validate

func (fs *FactoidState) Validate(index int, trans interfaces.ITransaction) (err error, holdAddr [32]byte)

Returns an error message about what is wrong with the transaction if it is invalid, otherwise you are good to go.

func (*FactoidState) ValidateTransactionAge

func (fs *FactoidState) ValidateTransactionAge(trans interfaces.ITransaction) error

Checks the transaction timestamp for validity in being included in the current No node has any responsibility to forward on transactions that do not fall within the timeframe around a block defined by TRANSACTION_PRIOR_LIMIT and TRANSACTION_POST_LIMIT

type FactoidTransaction

type FactoidTransaction struct {
	TxID         string
	Hash         string
	TotalInput   string
	Status       string
	TotalInputs  int
	TotalOutputs int
}

type FaultCore

type FaultCore struct {
	// The following 5 fields represent the "Core" of the message
	// This should match the Core of FullServerFault messages
	ServerID      interfaces.IHash
	AuditServerID interfaces.IHash
	VMIndex       byte
	DBHeight      uint32
	Height        uint32
	SystemHeight  uint32
	Timestamp     interfaces.Timestamp
}

func (*FaultCore) GetHash

func (fc *FaultCore) GetHash() (rval interfaces.IHash)

func (*FaultCore) MarshalCore

func (fc *FaultCore) MarshalCore() (data []byte, err error)

type GeneralMSGQueue

type GeneralMSGQueue chan interfaces.IMsg

Returning this is non-instrumented way

func (GeneralMSGQueue) BlockingDequeue

func (q GeneralMSGQueue) BlockingDequeue() interfaces.IMsg

func (GeneralMSGQueue) Cap

func (q GeneralMSGQueue) Cap() int

Cap of underlying channel

func (GeneralMSGQueue) Dequeue

func (q GeneralMSGQueue) Dequeue() interfaces.IMsg

Dequeue returns the channel dequeue

func (GeneralMSGQueue) Enqueue

func (q GeneralMSGQueue) Enqueue(t interfaces.IMsg)

Enqueue adds item to channel

func (GeneralMSGQueue) Length

func (q GeneralMSGQueue) Length() int

Length of underlying channel

type GenericListItem

type GenericListItem interface {
	Height() uint32
}

type HardGrant

type HardGrant struct {
	DBh     uint32
	Amount  uint64
	Address interfaces.IAddress
}

func GetHardCodedGrants

func GetHardCodedGrants() []HardGrant

Return the Hard Coded Grants. Buried in an func so other code cannot easily Address the array and change it

type HoldingList

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

This hold a slice of messages dependent on a hash

func (*HoldingList) Add

func (l *HoldingList) Add(h [32]byte, msg interfaces.IMsg) bool

Add a message to a dependent holding list

func (*HoldingList) ExecuteForNewHeight

func (l *HoldingList) ExecuteForNewHeight(ht uint32, minute int)

func (*HoldingList) Get

func (l *HoldingList) Get(h [32]byte) []interfaces.IMsg

get and remove the list of dependent message for a hash

func (*HoldingList) GetDependentMsg

func (l *HoldingList) GetDependentMsg(h [32]byte) interfaces.IMsg

Get a single msg from dependent holding

func (*HoldingList) GetSize

func (l *HoldingList) GetSize() int

func (*HoldingList) Init

func (l *HoldingList) Init(s *State)

func (*HoldingList) Messages

func (l *HoldingList) Messages() map[[32]byte][]interfaces.IMsg

func (*HoldingList) RemoveDependentMsg

func (l *HoldingList) RemoveDependentMsg(h [32]byte, reason string)

remove a single msg from dependent holding (done when we add it to the process list).

func (*HoldingList) Review

func (l *HoldingList) Review()

clean stale messages from holding

type IPrometheusRateMethods

type IPrometheusRateMethods interface {
	// Arrival
	SetArrivalInstantAvg(v float64)
	SetArrivalTotalAvg(v float64)
	SetArrivalBackup(v float64)
	SetMovingArrival(v float64)

	// Complete
	SetCompleteInstantAvg(v float64)
	SetCompleteTotalAvg(v float64)
	SetMovingComplete(v float64)
}

IPrometheusRateMethods indicated which prometheus counters/gauges to set

type IdentityEntry

type IdentityEntry struct {
	Entry       interfaces.IEBEntry
	Timestamp   interfaces.Timestamp
	Blockheight uint32
}

type InMsgMSGQueue

type InMsgMSGQueue chan interfaces.IMsg

InMsgMSGQueue counts incoming and outgoing messages for inmsg queue

func NewInMsgQueue

func NewInMsgQueue(capacity int) InMsgMSGQueue

func (InMsgMSGQueue) BlockingDequeue

func (q InMsgMSGQueue) BlockingDequeue() interfaces.IMsg

BlockingDequeue will block until it retrieves from queue

func (InMsgMSGQueue) Cap

func (q InMsgMSGQueue) Cap() int

Cap of underlying channel

func (InMsgMSGQueue) Dequeue

func (q InMsgMSGQueue) Dequeue() interfaces.IMsg

Dequeue removes an item from channel and instruments based on type. Returns nil if nothing in queue

func (InMsgMSGQueue) Enqueue

func (q InMsgMSGQueue) Enqueue(m interfaces.IMsg)

Enqueue adds item to channel and instruments based on type

func (InMsgMSGQueue) Length

func (q InMsgMSGQueue) Length() int

Length of underlying channel

type Last100

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

func (*Last100) Add

func (list *Last100) Add(msg interfaces.IMsg)

func (*Last100) Get

func (list *Last100) Get(h [32]byte) interfaces.IMsg

type MMRInfo

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

type MSGMap

type MSGMap struct {
	Msgs     map[[32]byte]interfaces.IMsg
	MsgOrder [1000][32]byte
	N        int
}

map of the last N messages indexed by hash

type MSgPair

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

type MarshalableUint32

type MarshalableUint32 uint32

func (*MarshalableUint32) MarshalBinary

func (m *MarshalableUint32) MarshalBinary() (rval []byte, err error)

func (*MarshalableUint32) UnmarshalBinary

func (m *MarshalableUint32) UnmarshalBinary(data []byte) error

func (*MarshalableUint32) UnmarshalBinaryData

func (m *MarshalableUint32) UnmarshalBinaryData(data []byte) ([]byte, error)

type MissingEntry

type MissingEntry struct {
	Cnt       int
	LastTime  time.Time
	EBHash    interfaces.IHash
	EntryHash interfaces.IHash
	DBHeight  uint32
}

func RandomMissingEntry

func RandomMissingEntry() *MissingEntry

func (*MissingEntry) IsSameAs

func (s *MissingEntry) IsSameAs(b *MissingEntry) bool

func (*MissingEntry) MarshalBinary

func (s *MissingEntry) MarshalBinary() (rval []byte, err error)

func (*MissingEntry) UnmarshalBinary

func (s *MissingEntry) UnmarshalBinary(p []byte) error

func (*MissingEntry) UnmarshalBinaryData

func (s *MissingEntry) UnmarshalBinaryData(p []byte) (newData []byte, err error)

type MissingEntryBlock

type MissingEntryBlock struct {
	EBHash   interfaces.IHash
	DBHeight uint32
}

func RandomMissingEntryBlock

func RandomMissingEntryBlock() *MissingEntryBlock

func (*MissingEntryBlock) IsSameAs

func (s *MissingEntryBlock) IsSameAs(b *MissingEntryBlock) bool

func (*MissingEntryBlock) MarshalBinary

func (s *MissingEntryBlock) MarshalBinary() (rval []byte, err error)

func (*MissingEntryBlock) UnmarshalBinary

func (s *MissingEntryBlock) UnmarshalBinary(p []byte) error

func (*MissingEntryBlock) UnmarshalBinaryData

func (s *MissingEntryBlock) UnmarshalBinaryData(p []byte) (newData []byte, err error)

type MissingMessageResponseCache

type MissingMessageResponseCache struct {
	// MissingMsgRequests is the channel on which we receive acked messages to cache
	MissingMsgRequests chan interfaces.IMsg
	// ProcessedPairs is all the ack+msg pairs that we processed
	ProcessedPairs chan *MsgPair

	// AckMessageCache is the cached acks from the last 2 blocks
	AckMessageCache *AckMsgPairCache
	// contains filtered or unexported fields
}

MissingMessageResponseCache will cache all processlist items from the last 2 blocks. It can create MissingMessageResponses to peer requests, and prevent us from asking the network if we already have something locally.

func NewMissingMessageReponseCache

func NewMissingMessageReponseCache(s *State) *MissingMessageResponseCache

func (*MissingMessageResponseCache) Close

func (mmrc *MissingMessageResponseCache) Close()

func (*MissingMessageResponseCache) NotifyNewMsgPair

func (mmrc *MissingMessageResponseCache) NotifyNewMsgPair(ack interfaces.IMsg, msg interfaces.IMsg)

NotifyNewMsgPair is the threadsafe way to include a new msg pair to respond to missing message requests from peers

func (*MissingMessageResponseCache) NotifyPeerMissingMsg

func (mmrc *MissingMessageResponseCache) NotifyPeerMissingMsg(missingMsg interfaces.IMsg)

NotifyPeerMissingMsg is the threadsafe way to notify that a peer sent us a missing message

func (*MissingMessageResponseCache) Run

func (mmrc *MissingMessageResponseCache) Run()

Run will start the loop to read messages from the channel and build the cache to respond to missing message requests

type MissingState

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

MissingState is information about a DBState that is known to exist but is not available on the current node.

func NewMissingState

func NewMissingState(height uint32) *MissingState

NewMissingState creates a new MissingState for the DBState at a specific height.

func (*MissingState) Height

func (s *MissingState) Height() uint32

type MovingAverage

type MovingAverage struct {
	Window int
	// contains filtered or unexported fields
}

func NewMovingAverage

func NewMovingAverage(window int) *MovingAverage

func (*MovingAverage) Add

func (ma *MovingAverage) Add(val float64)

func (*MovingAverage) Avg

func (ma *MovingAverage) Avg() float64

type MsgHeight

type MsgHeight struct {
	DBHeight int
	VM       int
	Height   int
}

type MsgPair

type MsgPair struct {
	Ack interfaces.IMsg
	Msg interfaces.IMsg
}

The pair of messages for a missing message response

type NetOutMsgQueue

type NetOutMsgQueue chan interfaces.IMsg

NetOutMsgQueue counts incoming and outgoing messages for netout queue

func NewNetOutMsgQueue

func NewNetOutMsgQueue(capacity int) NetOutMsgQueue

func (NetOutMsgQueue) BlockingDequeue

func (q NetOutMsgQueue) BlockingDequeue() interfaces.IMsg

BlockingDequeue will block until it retrieves from queue

func (NetOutMsgQueue) Cap

func (q NetOutMsgQueue) Cap() int

Cap of underlying channel

func (NetOutMsgQueue) Dequeue

func (q NetOutMsgQueue) Dequeue() interfaces.IMsg

Dequeue removes an item from channel and instruments based on type. Returns nil if nothing in queue

func (NetOutMsgQueue) Enqueue

func (q NetOutMsgQueue) Enqueue(m interfaces.IMsg)

Enqueue adds item to channel and instruments based on type

func (NetOutMsgQueue) Length

func (q NetOutMsgQueue) Length() int

Length of underlying channel

type ProcessList

type ProcessList struct {
	DBHeight uint32 // The directory block height for these lists

	// Temporary balances from updating transactions in real time.
	FactoidBalancesT      map[[32]byte]int64
	FactoidBalancesTMutex sync.Mutex
	ECBalancesT           map[[32]byte]int64
	ECBalancesTMutex      sync.Mutex

	State     *State
	VMs       []*VM       // Process list for each server (up to 32)
	ServerMap [10][64]int // Map of FedServers to all Servers for each minute
	System    VM          // System Faults and other system wide messages

	// messages processed in this list
	OldMsgs map[[32]byte]interfaces.IMsg

	// Chains that are executed, but not processed. There is a small window of a pending chain that the ack
	// will pass and the chainhead will fail. This covers that window. This is only used by WSAPI,
	// do not use it anywhere internally.
	PendingChainHeads *SafeMsgMap

	OldAcks map[[32]byte]interfaces.IMsg

	// Entry Blocks added within 10 minutes (follower and leader)
	NewEBlocks map[[32]byte]interfaces.IEntryBlock

	NewEntriesMutex sync.RWMutex
	NewEntries      map[[32]byte]interfaces.IEntry

	// State information about the directory block while it is under construction.  We may
	// have to start building the next block while still building the previous block.
	AdminBlock       interfaces.IAdminBlock
	EntryCreditBlock interfaces.IEntryCreditBlock
	DirectoryBlock   interfaces.IDirectoryBlock

	// Number of Servers acknowledged by Factom
	Matryoshka   []interfaces.IHash   // Reverse Hash
	AuditServers []interfaces.IServer // List of Audit Servers
	FedServers   []interfaces.IServer // List of Federated Servers

	// The Fedlist and Audlist at the START of the block. Server faults
	// can change the list, and we can calculate the deltas at the end
	StartingAuditServers []interfaces.IServer // List of Audit Servers
	StartingFedServers   []interfaces.IServer // List of Federated Servers

	// DB Sigs
	DBSignatures     []DBSig
	DBSigAlreadySent bool

	NextHeightToProcess [64]int
	// contains filtered or unexported fields
}

func NewProcessList

func NewProcessList(state interfaces.IState, previous *ProcessList, dbheight uint32) *ProcessList

func (*ProcessList) AddAuditServer

func (p *ProcessList) AddAuditServer(identityChainID interfaces.IHash) int

Add the given serverChain to this processlist as an Audit Server, and return the server index number of the added server

func (*ProcessList) AddDBSig

func (p *ProcessList) AddDBSig(serverID interfaces.IHash, sig interfaces.IFullSignature)

func (*ProcessList) AddFedServer

func (p *ProcessList) AddFedServer(identityChainID interfaces.IHash) int

Add the given serverChain to this processlist as a Federated Server, and return the server index number of the added server

func (*ProcessList) AddNewEBlocks

func (p *ProcessList) AddNewEBlocks(key interfaces.IHash, value interfaces.IEntryBlock)

func (*ProcessList) AddNewEntry

func (p *ProcessList) AddNewEntry(key interfaces.IHash, value interfaces.IEntry)

func (*ProcessList) AddOldMsgs

func (p *ProcessList) AddOldMsgs(m interfaces.IMsg)

func (*ProcessList) AddToProcessList

func (p *ProcessList) AddToProcessList(s *State, ack *messages.Ack, m interfaces.IMsg)

func (*ProcessList) CheckDiffSigTally

func (p *ProcessList) CheckDiffSigTally() bool

func (*ProcessList) Complete

func (p *ProcessList) Complete() bool

func (*ProcessList) ContainsDBSig

func (p *ProcessList) ContainsDBSig(serverID interfaces.IHash) bool

func (*ProcessList) CountFederatedServersAddedAndRemoved

func (p *ProcessList) CountFederatedServersAddedAndRemoved() (added int, removed int)

func (*ProcessList) FedServerFor

func (p *ProcessList) FedServerFor(minute int, hash []byte) interfaces.IServer

Returns the Federated Server responsible for this hash in this minute

func (*ProcessList) GetAckAt

func (p *ProcessList) GetAckAt(vmIndex int, height int) *messages.Ack

Given a server index, return the last Ack

func (*ProcessList) GetAuditServerIndexHash

func (p *ProcessList) GetAuditServerIndexHash(identityChainID interfaces.IHash) (bool, int)

Returns true and the index of this server, or false and the insertion point for this server

func (*ProcessList) GetDBHeight

func (p *ProcessList) GetDBHeight() uint32

func (*ProcessList) GetFedServerIndexHash

func (p *ProcessList) GetFedServerIndexHash(identityChainID interfaces.IHash) (bool, int)

Returns true and the index of this server, or false and the insertion point for this server

func (*ProcessList) GetKeysNewEntries

func (p *ProcessList) GetKeysNewEntries() (keys [][32]byte)

func (*ProcessList) GetNewEBlocks

func (p *ProcessList) GetNewEBlocks(key interfaces.IHash) interfaces.IEntryBlock

func (*ProcessList) GetNewEntry

func (p *ProcessList) GetNewEntry(key [32]byte) interfaces.IEntry

func (*ProcessList) GetOldAck

func (p *ProcessList) GetOldAck(key interfaces.IHash) interfaces.IMsg

func (*ProcessList) GetVMStatsForFedServer

func (p *ProcessList) GetVMStatsForFedServer(index int) (vmIndex int, listHeight int, listLength int, nextNil int)

func (*ProcessList) GetVirtualServers

func (p *ProcessList) GetVirtualServers(minute int, identityChainID interfaces.IHash) (found bool, index int)

func (*ProcessList) IncrementDiffSigTally

func (p *ProcessList) IncrementDiffSigTally()

func (*ProcessList) IsPendingChainHead

func (p *ProcessList) IsPendingChainHead(chainid interfaces.IHash) bool

IsPendingChainHead returns if a chainhead is about to be updated (In PL)

func (*ProcessList) LenNewEntries

func (p *ProcessList) LenNewEntries() int

func (*ProcessList) LogPrintLeaders

func (p *ProcessList) LogPrintLeaders(log string)

func (*ProcessList) MakeMap

func (p *ProcessList) MakeMap()

func (*ProcessList) PrintMap

func (p *ProcessList) PrintMap() string

This function will be replaced by a calculation from the Matryoshka hashes from the servers but for now, we are just going to make it a function of the dbheight.

func (*ProcessList) Process

func (p *ProcessList) Process(s *State) (progress bool)

Process messages and update our state.

func (*ProcessList) RemoveAuditServerHash

func (p *ProcessList) RemoveAuditServerHash(identityChainID interfaces.IHash)

Remove the given serverChain from this processlist's Audit Servers

func (*ProcessList) RemoveFedServerHash

func (p *ProcessList) RemoveFedServerHash(identityChainID interfaces.IHash)

Remove the given serverChain from this processlist's Federated Servers

func (*ProcessList) RemoveFromPL

func (p *ProcessList) RemoveFromPL(vm *VM, j int, reason string)

func (*ProcessList) Reset

func (p *ProcessList) Reset() bool

Intended to let a demoted leader come back before the next DB state but interfered with boot under load so disable for now that means demoted leaders are not sane till the next DBState (up to 10 minutes). Maybe revisit after the missing message storms are fixed.

func (*ProcessList) ResetDiffSigTally

func (p *ProcessList) ResetDiffSigTally()

func (*ProcessList) SetStartingAuthoritySet

func (p *ProcessList) SetStartingAuthoritySet()

Will set the starting fed/aud list for delta comparison at the end of the block

func (*ProcessList) Sort

func (p *ProcessList) Sort(serv []interfaces.IServer) bool

duplicate function in election but cannot import because of a dependency loop

func (*ProcessList) SortAuditServers

func (p *ProcessList) SortAuditServers()

func (*ProcessList) SortDBSigs

func (p *ProcessList) SortDBSigs()

func (*ProcessList) SortFedServers

func (p *ProcessList) SortFedServers()

func (*ProcessList) String

func (p *ProcessList) String() string

func (*ProcessList) TrimVMList

func (p *ProcessList) TrimVMList(h uint32, vmIndex int)

func (*ProcessList) UpdateStatus

func (p *ProcessList) UpdateStatus(s *State)

func (*ProcessList) VMIndexFor

func (p *ProcessList) VMIndexFor(hash []byte) int

Returns the Virtual Server index for this hash for the given minute

type ProcessLists

type ProcessLists struct {
	State        *State         // Pointer to the state object
	DBHeightBase uint32         // Height of the first Process List in this structure.
	Lists        []*ProcessList // Pointer to the ProcessList structure for each DBHeight under construction
	SetString    bool
	Str          string
}

func NewProcessLists

func NewProcessLists(state interfaces.IState) *ProcessLists

func (*ProcessLists) Get

func (lists *ProcessLists) Get(dbheight uint32) *ProcessList

func (*ProcessLists) GetSafe

func (lists *ProcessLists) GetSafe(dbheight uint32) (pl *ProcessList)

Only gets an existing process list

func (*ProcessLists) LastList

func (lists *ProcessLists) LastList() *ProcessList

func (*ProcessLists) String

func (lists *ProcessLists) String() string

func (*ProcessLists) UpdateState

func (lists *ProcessLists) UpdateState(dbheight uint32) (progress bool)

UpdateState is executed from a Follower's perspective. So the block we are building is always the block above the HighestRecordedBlock, but we only care about messages that are at the highest known block, as long as that is above the highest recorded block.

type RateCalculator

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

RateCalculator will maintain the rate of msgs arriving and rate of msgs leaving a queue. The instant rate is a 2s avg

func NewRateCalculator

func NewRateCalculator(p IPrometheusRateMethods) *RateCalculator

func NewRateCalculatorTime

func NewRateCalculatorTime(p IPrometheusRateMethods, td time.Duration) *RateCalculator

NewRateCalculatorTime is good for unit tests, or if you want to change the measureing time

func (*RateCalculator) Arrival

func (r *RateCalculator) Arrival()

Arrival indicates a new item added to the queue

func (*RateCalculator) Complete

func (r *RateCalculator) Complete()

Complete indicates something left the queue

func (*RateCalculator) Start

func (r *RateCalculator) Start()

Start begins instrumentation

func (*RateCalculator) StartTime

func (r *RateCalculator) StartTime(start time.Time)

StartTime is good for unit tests

type ReceivedState

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

ReceivedState represents a DBStateMsg received from the network

func NewReceivedState

func NewReceivedState(msg *messages.DBStateMsg) *ReceivedState

NewReceivedState creates a new member for the StatesReceived list

func (*ReceivedState) Height

func (s *ReceivedState) Height() uint32

Height returns the block height of the received state

func (*ReceivedState) Message

func (s *ReceivedState) Message() *messages.DBStateMsg

Message returns the DBStateMsg received from the network.

type RecentMessage

type RecentMessage struct {
	AcksMap ACKMap
	MsgsMap MSGMap
	NewMsgs chan interfaces.IMsg
}

Keep the history last N acks and Ackable messages

func (*RecentMessage) Add

func (m *RecentMessage) Add(msg interfaces.IMsg)

Adds messages to a map The map of messages will be used in tandem with the ack map when we get an MMR to ensure we don't ask for a message we already have.

func (*RecentMessage) GetAckAndMsg

func (am *RecentMessage) GetAckAndMsg(DBHeight int, vmIndex int, height int, s interfaces.IState) (ack interfaces.IMsg, msg interfaces.IMsg)

Called when we receive an ask for an MMR, we check to see if we have an ack and message in out Ask amd Message maps

func (*RecentMessage) HandleRejection

func (m *RecentMessage) HandleRejection(msg interfaces.IMsg, iAck interfaces.IMsg)

If a message is rejected we need to delete it from the recent message history so we will ask a neighbor

type Replay

type Replay struct {
	Mutex    sync.Mutex
	Buckets  [numBuckets]map[[32]byte]int
	Basetime int // hours since 1970
	Center   int // Hour of the current time.
	// contains filtered or unexported fields
}

func RandomReplay

func RandomReplay() *Replay

func (*Replay) Clear

func (r *Replay) Clear(mask int, hash [32]byte)

func (*Replay) Init

func (r *Replay) Init()

func (*Replay) IsHashUnique

func (r *Replay) IsHashUnique(mask int, hash [32]byte) bool

Returns True if there is no record of this hash in the Replay structures. Returns false if we have seen this hash before.

func (*Replay) IsHashUnique_internal

func (r *Replay) IsHashUnique_internal(mask int, hash [32]byte) bool

Returns True if there is no record of this hash in the Replay structures. Returns false if we have seen this hash before. Assume locking is done by caller

func (*Replay) IsSameAs

func (a *Replay) IsSameAs(b *Replay) bool

func (*Replay) IsTSValid

func (r *Replay) IsTSValid(mask int, hash interfaces.IHash, timestamp interfaces.Timestamp) bool

Checks if the timestamp is valid. If the timestamp is too old or too far into the future, then we don't consider it valid. Or if we have seen this hash before, then it is not valid. To that end, this code remembers hashes tested in the past, and rejects the second submission of the same hash.

func (*Replay) IsTSValidAndUpdateState

func (r *Replay) IsTSValidAndUpdateState(mask int, hash [32]byte, timestamp interfaces.Timestamp, systemtime interfaces.Timestamp) (rval bool)

To make the function testable, the logic accepts the current time as a parameter. This way, the test code can manipulate the clock at will.

func (*Replay) MarshalBinary

func (r *Replay) MarshalBinary() (rval []byte, err error)

func (*Replay) Recenter

func (r *Replay) Recenter(systemtime interfaces.Timestamp)

This move the center time of the replay filter to the current systemtime. Really it should track the time for the current block.

func (*Replay) Save

func (r *Replay) Save() *Replay

func (*Replay) SetHashNow

func (r *Replay) SetHashNow(mask int, hash [32]byte, now interfaces.Timestamp) bool

Fixed conflicting lock path Add a hash/mask at a specific time if it did not exist prior.

func (*Replay) UnmarshalBinary

func (r *Replay) UnmarshalBinary(p []byte) error

func (*Replay) UnmarshalBinaryData

func (r *Replay) UnmarshalBinaryData(p []byte) ([]byte, error)

func (*Replay) Valid

func (r *Replay) Valid(mask int, hash [32]byte, timestamp interfaces.Timestamp, systemtime interfaces.Timestamp) (index int, valid bool)

Returns false if the hash is too old, or is already a member of the set. Timestamp is in seconds. Does not add the hash to the buckets!

type SafeMsgMap

type SafeMsgMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SafeMsgMap is a threadsafe map[[32]byte]interfaces.IMsg

func NewSafeMsgMap

func NewSafeMsgMap(name string, s *State) *SafeMsgMap

func (*SafeMsgMap) Cleanup

func (m *SafeMsgMap) Cleanup(s *State)

Cleanup will clean old elements out from the commit map.

func (*SafeMsgMap) Copy

func (m *SafeMsgMap) Copy() *SafeMsgMap

func (*SafeMsgMap) Delete

func (m *SafeMsgMap) Delete(key [32]byte) (msg interfaces.IMsg, found bool)

func (*SafeMsgMap) Get

func (m *SafeMsgMap) Get(key [32]byte) (msg interfaces.IMsg)

func (*SafeMsgMap) GetRaw

func (m *SafeMsgMap) GetRaw() map[[32]byte]interfaces.IMsg

GetRaw is used in testing and simcontrol. Do no use this in production

func (*SafeMsgMap) Len

func (m *SafeMsgMap) Len() int

func (*SafeMsgMap) Put

func (m *SafeMsgMap) Put(key [32]byte, msg interfaces.IMsg)

func (*SafeMsgMap) RemoveExpired

func (m *SafeMsgMap) RemoveExpired(s *State)

RemoveExpired is used when treating this as a commit map. Do not

func (*SafeMsgMap) Reset

func (m *SafeMsgMap) Reset()

Reset will delete all elements

type SaveState

type SaveState struct {
	DBHeight uint32

	FedServers   []interfaces.IServer
	AuditServers []interfaces.IServer

	// The old balances must be restored
	FactoidBalancesP map[[32]byte]int64
	ECBalancesP      map[[32]byte]int64

	IdentityControl *IdentityManager // Identities

	AuthorityServerCount int // number of federated or audit servers allowed

	// Server State
	LLeaderHeight uint32
	Leader        bool
	LeaderVMIndex int
	LeaderPL      *ProcessList
	CurrentMinute int

	EOMsyncing bool

	EOM          bool // Set to true when the first EOM is encountered
	EOMLimit     int
	EOMProcessed int
	EOMDone      bool
	EOMMinute    int
	EOMSys       bool // At least one EOM has covered the System List

	DBSig          bool
	DBSigLimit     int
	DBSigProcessed int // Number of DBSignatures received and processed.
	DBSigDone      bool
	DBSigSys       bool // At least one DBSig has covered the System List

	Newblk  bool // True if we are starting a new block, and a dbsig is needed.
	Saving  bool // True if we are in the process of saving to the database
	Syncing bool // Looking for messages from leaders to sync

	LeaderTimestamp interfaces.Timestamp

	Holding map[[32]byte]interfaces.IMsg // Hold Messages
	XReview []interfaces.IMsg            // After the EOM, we must review the messages in Holding
	Acks    map[[32]byte]interfaces.IMsg // Hold Acknowledgements
	Commits *SafeMsgMap                  // map[[32]byte]interfaces.IMsg // Commit Messages

	InvalidMessages map[[32]byte]interfaces.IMsg

	// DBlock Height at which node has a complete set of eblocks+entries
	EntryBlockDBHeightComplete uint32
	// DBlock Height at which we have started asking for entry blocks
	EntryBlockDBHeightProcessing uint32

	// FER section
	FactoshisPerEC                 uint64
	FERChainId                     string
	ExchangeRateAuthorityPublicKey string

	FERChangeHeight      uint32
	FERChangePrice       uint64
	FERPriority          uint32
	FERPrioritySetHeight uint32
}

Because we have to go back to a previous state should the network be partitioned and we are on a separate branch, we need to log our state periodically so we can reset to a state prior to the network partition. The need to go back to a SaveState should be rare. And even more rare would be the need to go back two levels. However, it is possible that a minority partition is able to see a level of consensus and save a state to disk that the majority of the nodes did not see. However it is not possible for this to occur more than once. This is because any consensus a node can see requires that all the nodes saw the previous consensus.

func SaveFactomdState

func SaveFactomdState(state *State, d *DBState) (ss *SaveState)

func (*SaveState) Init

func (ss *SaveState) Init()

func (*SaveState) IsSameAs

func (a *SaveState) IsSameAs(b *SaveState) bool

func (*SaveState) JSONByte

func (e *SaveState) JSONByte() ([]byte, error)

func (*SaveState) JSONString

func (e *SaveState) JSONString() (string, error)

func (*SaveState) MarshalBinary

func (ss *SaveState) MarshalBinary() (rval []byte, err error)

func (*SaveState) RestoreFactomdState

func (ss *SaveState) RestoreFactomdState(s *State)

func (*SaveState) String

func (e *SaveState) String() string

func (*SaveState) TrimBack

func (ss *SaveState) TrimBack(s *State, d *DBState)

func (*SaveState) UnmarshalBinary

func (ss *SaveState) UnmarshalBinary(p []byte) error

func (*SaveState) UnmarshalBinaryData

func (ss *SaveState) UnmarshalBinaryData(p []byte) (newData []byte, err error)

type Server

type Server struct {
	ChainID interfaces.IHash
	Name    string
	Online  bool
	Replace interfaces.IHash
}

func (*Server) GetChainID

func (s *Server) GetChainID() (rval interfaces.IHash)

func (*Server) GetName

func (s *Server) GetName() string

func (*Server) Init

func (s *Server) Init()

func (*Server) IsOnline

func (s *Server) IsOnline() bool

func (*Server) IsSameAs

func (s *Server) IsSameAs(b interfaces.IServer) bool

func (*Server) JSONByte

func (e *Server) JSONByte() ([]byte, error)

func (*Server) JSONString

func (e *Server) JSONString() (string, error)

func (*Server) LeaderToReplace

func (s *Server) LeaderToReplace() (rval interfaces.IHash)

func (*Server) MarshalBinary

func (s *Server) MarshalBinary() (rval []byte, err error)

func (*Server) SetOnline

func (s *Server) SetOnline(o bool)

func (*Server) SetReplace

func (s *Server) SetReplace(h interfaces.IHash)

func (*Server) String

func (s *Server) String() string

func (*Server) UnmarshalBinary

func (s *Server) UnmarshalBinary(p []byte) error

func (*Server) UnmarshalBinaryData

func (s *Server) UnmarshalBinaryData(p []byte) (newData []byte, err error)

type State

type State struct {
	Logger            *log.Entry
	RunState          runstate.RunState
	NetworkController *p2p.Network
	Salt              interfaces.IHash
	Cfg               interfaces.IFactomConfig
	ConfigFilePath    string // $HOME/.factom/m2/factomd.conf by default

	Prefix          string
	FactomNodeName  string
	FactomdVersion  string
	LogPath         string
	LdbPath         string
	BoltDBPath      string
	LogLevel        string
	ConsoleLogLevel string
	NodeMode        string
	DBType          string
	CheckChainHeads struct {
		CheckChainHeads bool
		Fix             bool
	}
	CloneDBType       string
	ExportData        bool
	ExportDataSubpath string

	LogBits int64 // Bit zero is for logging the Directory Block on DBSig [5]

	DBStatesSent            []*interfaces.DBStateSent
	DBStatesReceivedBase    int
	DBStatesReceived        []*messages.DBStateMsg
	LocalServerPrivKey      string
	DirectoryBlockInSeconds int
	PortNumber              int
	Replay                  *Replay
	FReplay                 *Replay
	CrossReplay             *CrossReplayFilter
	DropRate                int
	Delay                   int64 // Simulation delays sending messages this many milliseconds

	ControlPanelPort    int
	ControlPanelSetting int
	// Keeping the last display state lets us know when to send over the new blocks
	LastDisplayState        *DisplayState
	ControlPanelChannel     chan DisplayState
	ControlPanelDataRequest bool // If true, update Display state

	// Network Configuration
	Network                 string
	MainNetworkPort         string
	PeersFile               string
	MainSeedURL             string
	MainSpecialPeers        string
	TestNetworkPort         string
	TestSeedURL             string
	TestSpecialPeers        string
	LocalNetworkPort        string
	LocalSeedURL            string
	LocalSpecialPeers       string
	CustomNetworkPort       string
	CustomSeedURL           string
	CustomSpecialPeers      string
	CustomNetworkID         []byte
	CustomBootstrapIdentity string
	CustomBootstrapKey      string

	IdentityChainID interfaces.IHash // If this node has an identity, this is it
	//Identities      []*Identity      // Identities of all servers in management chain
	// Authorities          []*Authority     // Identities of all servers in management chain
	AuthorityServerCount int // number of federated or audit servers allowed
	IdentityControl      *IdentityManager

	// Just to print (so debugging doesn't drive functionality)
	Status int // Return a status (0 do nothing, 1 provide queues, 2 provide consensus data)

	StatusMutex sync.Mutex
	StatusStrs  []string
	Starttime   time.Time

	ResetTryCnt int
	ResetCnt    int

	//  pending entry/transaction api calls for the holding queue do not have proper scope
	//  This is used to create a temporary, correctly scoped holding queue snapshot for the calls on demand
	HoldingMutex sync.RWMutex
	HoldingLast  int64
	HoldingMap   map[[32]byte]interfaces.IMsg

	// Elections are managed through the Elections Structure
	EFactory  interfaces.IElectionsFactory
	Elections interfaces.IElections
	Election0 string // Title
	Election1 string // Election state for display
	Election2 string // Election state for display
	Election3 string // Election leader list

	//  pending entry/transaction api calls for the ack queue do not have proper scope
	//  This is used to create a temporary, correctly scoped ackqueue snapshot for the calls on demand
	AcksMutex sync.RWMutex
	AcksLast  int64
	AcksMap   map[[32]byte]interfaces.IMsg

	DBStateAskCnt     int
	DBStateReplyCnt   int
	DBStateIgnoreCnt  int
	DBStateAppliedCnt int

	MissingRequestAskCnt      int
	MissingRequestReplyCnt    int
	MissingRequestIgnoreCnt   int
	MissingResponseAppliedCnt int

	ResendCnt int
	ExpireCnt int

	TimeOffset    interfaces.Timestamp
	MaxTimeOffset interfaces.Timestamp

	ShutdownChan chan int // For gracefully halting Factom
	JournalFile  string
	Journaling   bool

	ServerPrivKey *primitives.PrivateKey
	ServerPubKey  *primitives.PublicKey

	// RPC connection config
	RpcUser     string
	RpcPass     string
	RpcAuthHash []byte

	FactomdTLSEnable   bool
	FactomdTLSKeyFile  string
	FactomdTLSCertFile string
	FactomdLocations   string

	CorsDomains []string
	// Server State
	StartDelay      int64 // Time in Milliseconds since the last DBState was applied
	StartDelayLimit int64
	DBFinished      bool
	RunLeader       bool
	BootTime        int64 // Time in seconds that we last booted
	EOMIssueTime    int64
	EOMSyncEnd      int64

	// Ignore missing messages for a period to allow rebooting a network where your
	// own messages from the previously executing network can confuse you.
	IgnoreDone    bool
	IgnoreMissing bool

	// Timout and Limit for outstanding missing DBState requests
	RequestTimeout int // timeout in seconds
	RequestLimit   int

	LLeaderHeight   uint32
	Leader          bool
	LeaderVMIndex   int
	LeaderPL        *ProcessList
	PLProcessHeight uint32
	// Height cutoff where no missing messages below this height
	DBHeightAtBoot  uint32
	TimestampAtBoot interfaces.Timestamp
	OneLeader       bool
	OutputAllowed   bool
	CurrentMinute   int

	// These are the start times for blocks and minutes
	PreviousMinuteStartTime int64
	CurrentMinuteStartTime  int64
	CurrentBlockStartTime   int64

	EOMsyncing   bool
	EOMSyncTime  int64
	EOM          bool // Set to true when the first EOM is encountered
	EOMLimit     int
	EOMProcessed int
	EOMDone      bool
	EOMMinute    int
	EOMSys       bool // At least one EOM has covered the System List

	DBSig          bool
	DBSigLimit     int
	DBSigProcessed int // Number of DBSignatures received and processed.
	DBSigDone      bool
	DBSigSys       bool // At least one DBSig has covered the System List

	CreatedLastBlockFromDBState bool

	// By default, this is false, which means DBstates are discarded
	// when a majority of leaders disagree with the hash we have via DBSigs
	KeepMismatch bool

	DBSigFails int // Keep track of how many blockhash mismatches we've had to correct

	Saving  bool // True if we are in the process of saving to the database
	Syncing bool // Looking for messages from leaders to sync

	NetStateOff     bool // Disable if true, Enable if false
	DebugConsensus  bool // If true, dump consensus trace
	FactoidTrans    int
	ECCommits       int
	ECommits        int
	FCTSubmits      int
	NewEntryChains  int
	NewEntries      int
	LeaderTimestamp interfaces.Timestamp

	// Maps
	// ====
	// For Follower
	ResendHolding interfaces.Timestamp         // Timestamp to gate resending holding to neighbors
	HoldingList   chan [32]byte                // Queue to process Holding in order
	HoldingVM     int                          // VM used to build current holding list
	Holding       map[[32]byte]interfaces.IMsg // Hold Messages
	XReview       []interfaces.IMsg            // After the EOM, we must review the messages in Holding
	Acks          map[[32]byte]interfaces.IMsg // Hold Acknowledgements
	Commits       *SafeMsgMap                  //  map[[32]byte]interfaces.IMsg // Commit Messages

	InvalidMessages      map[[32]byte]interfaces.IMsg
	InvalidMessagesMutex *sync.RWMutex

	AuditHeartBeats []interfaces.IMsg // The checklist of HeartBeats for this period

	FaultTimeout  int
	FaultWait     int
	EOMfaultIndex int
	LastTiebreak  int64

	AuthoritySetString string
	// Network MAIN = 0, TEST = 1, LOCAL = 2, CUSTOM = 3
	NetworkNumber int // Encoded into Directory Blocks(s.Cfg.(*util.FactomdConfig)).String()

	// Database
	DB     interfaces.DBOverlaySimple
	Anchor interfaces.IAnchor

	// Directory Block State
	DBStates       *DBStateList // Holds all DBStates not yet processed.
	StatesMissing  *StatesMissing
	StatesWaiting  *StatesWaiting
	StatesReceived *StatesReceived

	ResetRequest bool // Set to true to trigger a reset
	ProcessLists *ProcessLists

	AuthorityDeltas string

	// Factom State
	FactoidState    interfaces.IFactoidState
	NumTransactions int

	// Permanent balances from processing blocks.
	RestoreFCT            map[[32]byte]int64
	RestoreEC             map[[32]byte]int64
	FactoidBalancesPapi   map[[32]byte]int64
	FactoidBalancesP      map[[32]byte]int64
	FactoidBalancesPMutex sync.Mutex
	ECBalancesPapi        map[[32]byte]int64
	ECBalancesP           map[[32]byte]int64
	ECBalancesPMutex      sync.Mutex
	TempBalanceHash       interfaces.IHash
	Balancehash           interfaces.IHash

	// Web Services
	Port int

	// For Replay / journal
	IsReplaying     bool
	ReplayTimestamp interfaces.Timestamp

	// EntrySync handles the downloading of entries
	EntrySync *EntrySync

	MissingEntryBlockRepeat interfaces.Timestamp
	// DBlock Height at which node has a complete set of eblocks+entries
	EntryBlockDBHeightComplete uint32
	// DBlock Height at which we have started asking for entry blocks
	EntryBlockDBHeightProcessing uint32

	// Height in the Directory Block where we have
	// Entries we don't have that we are asking our neighbors for
	MissingEntries chan *MissingEntry

	// Holds leaders and followers up until all missing entries are processed, if true
	WaitForEntries  bool
	UpdateEntryHash chan *EntryUpdate // Channel for updating entry Hashes tracking (repeats and such)
	WriteEntry      chan interfaces.IEBEntry
	// MessageTally causes the node to keep track of (and display) running totals of each
	// type of message received during the tally interval
	MessageTally           bool
	MessageTalliesReceived [constants.NUM_MESSAGES]int
	MessageTalliesSent     [constants.NUM_MESSAGES]int

	LastPrint    string
	LastPrintCnt int

	// FER section
	FactoshisPerEC                 uint64
	FERChainId                     string
	ExchangeRateAuthorityPublicKey string

	FERChangeHeight      uint32
	FERChangePrice       uint64
	FERPriority          uint32
	FERPrioritySetHeight uint32

	AckChange uint32

	StateSaverStruct StateSaverStruct

	// Logstash
	UseLogstash bool
	LogstashURL string

	Uploader                *UploadController // Controls the uploads of torrents. Prevents backups
	DBStateManager          interfaces.IManagerController
	HighestCompletedTorrent uint32
	FastBoot                bool
	FastBootLocation        string
	FastSaveRate            int

	// These stats are collected when we write the dbstate to the database.
	NumNewChains   int // Number of new Chains in this block
	NumNewEntries  int // Number of new Entries, not counting the first entry in a chain
	NumEntries     int // Number of entries in this block (including the entries that create chains)
	NumEntryBlocks int // Number of Entry Blocks
	NumFCTTrans    int // Number of Factoid Transactions in this block

	SyncingState        [256]string
	SyncingStateCurrent int

	ProcessListProcessCnt int64 // count of attempts to process .. so we can see if the thread is running
	StateProcessCnt       int64
	StateUpdateState      int64
	ValidatorLoopSleepCnt int64

	ProcessTime interfaces.Timestamp
	MMRInfo     // fields for MMR processing

	OutputRegEx       *regexp.Regexp
	OutputRegExString string
	InputRegEx        *regexp.Regexp
	InputRegExString  string

	Hold         HoldingList
	EventService events.EventService

	// MissingMessageResponse is a cache of the last 1000 msgs we receive such that when
	// we send out a missing message, we can find that message locally before we ask the net
	RecentMessage

	// MissingMessageResponseHandler is a cache of the last 2 blocks of processed acks.
	// It can handle and respond to missing message requests on it's own thread.
	MissingMessageResponseHandler *MissingMessageResponseCache
	ChainCommits                  Last100
	Reveals                       Last100
	// contains filtered or unexported fields
}

func (*State) APIQueue

func (s *State) APIQueue() interfaces.IQueue

func (*State) AckQueue

func (s *State) AckQueue() chan interfaces.IMsg

func (*State) Add

func (s *State) Add(h [32]byte, msg interfaces.IMsg) int

Add a message to a dependent holding list

func (*State) AddAuditServer

func (s *State) AddAuditServer(dbheight uint32, hash interfaces.IHash) int

func (*State) AddAuthorityDelta

func (s *State) AddAuthorityDelta(authSet string)

func (*State) AddDBSig

func (s *State) AddDBSig(dbheight uint32, chainID interfaces.IHash, sig interfaces.IFullSignature)

func (*State) AddDBState

func (s *State) AddDBState(isNew bool,
	directoryBlock interfaces.IDirectoryBlock,
	adminBlock interfaces.IAdminBlock,
	factoidBlock interfaces.IFBlock,
	entryCreditBlock interfaces.IEntryCreditBlock,
	eBlocks []interfaces.IEntryBlock,
	entries []interfaces.IEBEntry) *DBState

Adds blocks that are either pulled locally from a database, or acquired from peers.

func (*State) AddFedServer

func (s *State) AddFedServer(dbheight uint32, hash interfaces.IHash) int

func (*State) AddIdentityEblocks

func (st *State) AddIdentityEblocks(cid interfaces.IHash, rootChain bool) error

AddIdentityEblocks will find all eblocks for a root/management chain and add them to the sync list

func (*State) AddIdentityFromChainID

func (st *State) AddIdentityFromChainID(cid interfaces.IHash) error

AddIdentityFromChainID will add an identity to our list to watch and sync it.

func (*State) AddNewIdentityEblocks

func (st *State) AddNewIdentityEblocks(eblocks []interfaces.IEntryBlock, dblockTimestamp interfaces.Timestamp)

AddNewIdentityEblocks will scan the new eblock list and identify any eblocks of interest. If an eblock belongs to a current identity, we add it to the eblock lists of the identity to be synced.

func (*State) AddPrefix

func (s *State) AddPrefix(prefix string)

func (*State) AddStatus

func (s *State) AddStatus(status string)

func (*State) AddToHolding

func (s *State) AddToHolding(hash [32]byte, msg interfaces.IMsg)

func (*State) AddToReplayFilter

func (s *State) AddToReplayFilter(mask int, hash [32]byte, timestamp interfaces.Timestamp, systemtime interfaces.Timestamp) (rval bool)

Check and Add a hash to the network replay filter

func (*State) Ask

func (s *State) Ask(DBHeight int, vmIndex int, height int, when int64) bool

Ask is called from ReportMissing which comes from validation thread to notify MMR that we are missing a message return false if we are unable to ask

func (*State) CalculateTransactionRate

func (s *State) CalculateTransactionRate() (totalTPS float64, instantTPS float64)

CalculateTransactionRate calculates how many transactions this node is processing

totalTPS	: Transaction rate over life of node (totaltime / totaltrans)
instantTPS	: Transaction rate weighted over last 3 seconds

func (*State) CheckFileName

func (s *State) CheckFileName(name string) bool

func (*State) CheckForIDChange

func (s *State) CheckForIDChange()

func (*State) Clone

func (s *State) Clone(cloneNumber int) interfaces.IState

func (*State) ComputeVMIndex

func (s *State) ComputeVMIndex(hash []byte) int

Returns the Virtual Server Index for this hash if this server is the leader; returns -1 if we are not the leader for this hash

func (*State) ConstructAuthoritySetString

func (s *State) ConstructAuthoritySetString() (authSets []string)

func (*State) CopyStateToControlPanel

func (s *State) CopyStateToControlPanel() error

Sends the copy of State over channel to control panel

func (*State) CreateDBSig

func (s *State) CreateDBSig(dbheight uint32, vmIndex int) (interfaces.IMsg, interfaces.IMsg)

func (*State) CreateEOM

func (s *State) CreateEOM(force bool, m interfaces.IMsg, vmIdx int) (eom *messages.EOM, ack interfaces.IMsg)

func (*State) CrossReplayAddSalt

func (s *State) CrossReplayAddSalt(height uint32, salt [8]byte) error

CrossReplayAddSalt adds the salt to the DB

func (*State) DataMsgQueue

func (s *State) DataMsgQueue() chan interfaces.IMsg

func (*State) DatabaseContains

func (s *State) DatabaseContains(hash interfaces.IHash) bool

func (*State) DebugExec

func (s *State) DebugExec() (ret bool)

func (*State) DeleteFromHolding

func (s *State) DeleteFromHolding(hash [32]byte, msg interfaces.IMsg, reason string)

func (*State) DidCreateLastBlockFromDBState

func (s *State) DidCreateLastBlockFromDBState() bool

func (*State) DoProcessing

func (s *State) DoProcessing()

This is the tread with access to state. It does process and update state

func (*State) DoReset

func (s *State) DoReset()

Set to reprocess all messages and states

func (*State) ElectionsQueue

func (s *State) ElectionsQueue() interfaces.IQueue

func (*State) EmitDirectoryBlockEventsFromHeight

func (s *State) EmitDirectoryBlockEventsFromHeight(height uint32, end uint32)

func (*State) ExchangeRateAuthorityIsValid

func (this *State) ExchangeRateAuthorityIsValid(e interfaces.IEBEntry) bool

func (*State) ExecuteFromHolding

func (s *State) ExecuteFromHolding(h [32]byte)

Execute a list of messages from holding that are dependent on a hash the hash may be a EC address or a ChainID or a height (ok heights are not really hashes but we cheat on that)

func (*State) ExpireHolding

func (s *State) ExpireHolding()

func (*State) FactomSecond

func (s *State) FactomSecond() time.Duration

FactomSecond finds the time duration of 1 second relative to 10min blocks.

Blktime			EOMs		Second
600s			60s			1s
300s			30s			0.5s
120s			12s			0.2s
 60s			 6s			0.1s
 30s			 3s			0.05s

func (*State) FastVerifyAuthoritySignature

func (st *State) FastVerifyAuthoritySignature(msg []byte, sig interfaces.IFullSignature, dbheight uint32) (int, error)

Checks the signature of a message. Returns an int based on who signed it:

1  -> Federated Signature
0  -> Audit Signature
-1 -> Neither Fed or Audit Signature

func (*State) FerEntryIsValid

func (this *State) FerEntryIsValid(passedFEREntry interfaces.IFEREntry) bool

func (*State) FetchECTransactionByHash

func (s *State) FetchECTransactionByHash(hash interfaces.IHash) (interfaces.IECBlockEntry, error)

func (*State) FetchEntryByHash

func (s *State) FetchEntryByHash(hash interfaces.IHash) (interfaces.IEBEntry, error)

func (*State) FetchEntryHashFromProcessListsByTxID

func (s *State) FetchEntryHashFromProcessListsByTxID(txID string) (interfaces.IHash, error)

might want to make this search the database at some point to be more generic

func (*State) FetchEntryRevealAndCommitFromHolding

func (s *State) FetchEntryRevealAndCommitFromHolding(hash interfaces.IHash) (reveal interfaces.IMsg, commit interfaces.IMsg)

FetchEntryRevealAndCommitFromHolding will look for the commit and reveal for a given hash. It will check the hash as an entryhash and a txid, and return any reveals that match the entryhash and any commits that match the entryhash or txid

Returns
	reveal = The reveal message if found
	commit = The commit message if found

func (*State) FetchFactoidTransactionByHash

func (s *State) FetchFactoidTransactionByHash(hash interfaces.IHash) (interfaces.ITransaction, error)

func (*State) FetchHoldingMessageByHash

func (s *State) FetchHoldingMessageByHash(hash interfaces.IHash) (int, byte, interfaces.IMsg, error)

func (*State) FetchIdentityChainEntriesInCreateOrder

func (s *State) FetchIdentityChainEntriesInCreateOrder(chainid interfaces.IHash) ([]IdentityEntry, error)

FetchIdentityChainEntriesInCreateOrder will grab all entries in a chain for an identity in the order they were created.

func (*State) FetchPaidFor

func (s *State) FetchPaidFor(hash interfaces.IHash) (interfaces.IHash, error)

func (*State) FixMissingKeys

func (s *State) FixMissingKeys(id *Identity) error

func (*State) FollowerExecuteAck

func (s *State) FollowerExecuteAck(msg interfaces.IMsg)

Ack messages always match some message in the Process List. That is done here, though the only msg that should call this routine is the Ack message.

func (*State) FollowerExecuteCommitChain

func (s *State) FollowerExecuteCommitChain(m interfaces.IMsg)

func (*State) FollowerExecuteCommitEntry

func (s *State) FollowerExecuteCommitEntry(m interfaces.IMsg)

func (*State) FollowerExecuteDBState

func (s *State) FollowerExecuteDBState(msg interfaces.IMsg)

func (*State) FollowerExecuteDataResponse

func (s *State) FollowerExecuteDataResponse(m interfaces.IMsg)

func (*State) FollowerExecuteEOM

func (s *State) FollowerExecuteEOM(m interfaces.IMsg)

Messages that will go into the Process List must match an Acknowledgement. The code for this is the same for all such messages, so we put it here.

Returns true if it finds a match, puts the message in holding, or invalidates the message

func (*State) FollowerExecuteFullFault

func (s *State) FollowerExecuteFullFault(m interfaces.IMsg)

When we execute a FullFault message, it could be complete (includes all necessary signatures + pledge) or incomplete, in which case it is just a negotiation ping

func (*State) FollowerExecuteMMR

func (s *State) FollowerExecuteMMR(m interfaces.IMsg)

func (*State) FollowerExecuteMissingMsg

func (s *State) FollowerExecuteMissingMsg(msg interfaces.IMsg)

func (*State) FollowerExecuteMsg

func (s *State) FollowerExecuteMsg(m interfaces.IMsg)

Messages that will go into the Process List must match an Acknowledgement. The code for this is the same for all such messages, so we put it here.

Returns true if it finds a match, puts the message in holding, or invalidates the message

func (*State) FollowerExecuteRevealEntry

func (s *State) FollowerExecuteRevealEntry(m interfaces.IMsg)

func (*State) FollowerExecuteSFault

func (s *State) FollowerExecuteSFault(m interfaces.IMsg)

func (*State) GetACKStatus

GetACKStatus also checks the oldmsgs map

func (*State) GetAckChange

func (s *State) GetAckChange() (bool, error)

func (*State) GetAnchor

func (s *State) GetAnchor() interfaces.IAnchor

func (*State) GetAuditHeartBeats

func (s *State) GetAuditHeartBeats() []interfaces.IMsg

func (*State) GetAuditServers

func (s *State) GetAuditServers(dbheight uint32) []interfaces.IServer

func (*State) GetAuthorities

func (s *State) GetAuthorities() []interfaces.IAuthority

GetAuthorities will return a list of the network authorities

func (*State) GetAuthority

func (st *State) GetAuthority(serverID interfaces.IHash) (*Authority, int)

Gets the authority matching the identity ChainID. Returns the authority and the int of its type:

1  ->  Federated
0  ->  Audit
-1 ->  Not fed or audit
-2 -> Not found

func (*State) GetAuthorityDeltas

func (s *State) GetAuthorityDeltas() string

func (*State) GetAuthorityInterface

func (s *State) GetAuthorityInterface(chainid interfaces.IHash) interfaces.IAuthority

GetAuthorityInterface will the authority as an interface. Because of import issues we cannot access IdentityControl Directly

func (*State) GetAuthorityServerType

func (st *State) GetAuthorityServerType(chainID interfaces.IHash) int

func (*State) GetAuthoritySetString

func (s *State) GetAuthoritySetString() string

func (*State) GetBootTime

func (s *State) GetBootTime() int64

func (*State) GetCfg

func (s *State) GetCfg() interfaces.IFactomConfig

Getting the cfg state for Factom doesn't force a read of the config file unless it hasn't been read yet.

func (*State) GetConfigPath

func (s *State) GetConfigPath() string

func (*State) GetCorsDomains

func (s *State) GetCorsDomains() []string

func (*State) GetCurrentBlockStartTime

func (s *State) GetCurrentBlockStartTime() int64

func (*State) GetCurrentMinute

func (s *State) GetCurrentMinute() int

func (*State) GetCurrentMinuteStartTime

func (s *State) GetCurrentMinuteStartTime() int64

func (*State) GetCurrentTime

func (s *State) GetCurrentTime() int64

func (*State) GetDB

func (s *State) GetDB() interfaces.DBOverlaySimple

func (*State) GetDBFinished

func (s *State) GetDBFinished() bool

func (*State) GetDBHeightAtBoot

func (s *State) GetDBHeightAtBoot() uint32

func (*State) GetDBHeightComplete

func (s *State) GetDBHeightComplete() uint32

func (*State) GetDBState

func (s *State) GetDBState(height uint32) *DBState

func (*State) GetDBStatesSent

func (s *State) GetDBStatesSent() []*interfaces.DBStateSent

func (*State) GetDelay

func (s *State) GetDelay() int64

func (*State) GetDirectoryBlock

func (s *State) GetDirectoryBlock() interfaces.IDirectoryBlock

func (*State) GetDirectoryBlockByHeight

func (s *State) GetDirectoryBlockByHeight(height uint32) interfaces.IDirectoryBlock

Return the Directory block if it is in memory, or hit the database if it must be loaded.

func (*State) GetDirectoryBlockInSeconds

func (s *State) GetDirectoryBlockInSeconds() int

func (*State) GetDropRate

func (s *State) GetDropRate() int

func (*State) GetE

func (s *State) GetE(rt bool, adr [32]byte) (v int64)

func (*State) GetEBlockKeyMRFromEntryHash

func (s *State) GetEBlockKeyMRFromEntryHash(entryHash interfaces.IHash) (rval interfaces.IHash)

func (*State) GetElections

func (s *State) GetElections() interfaces.IElections

func (*State) GetEntryBlockDBHeightComplete

func (s *State) GetEntryBlockDBHeightComplete() uint32

func (*State) GetEntryBlockDBHeightProcessing

func (s *State) GetEntryBlockDBHeightProcessing() uint32

func (*State) GetEntryCommitAckByEntryHash

func (s *State) GetEntryCommitAckByEntryHash(hash interfaces.IHash) (status int, commit interfaces.IMsg)

GetEntryCommitAck will fetch the status of a entrycommit by ENTRYHASH. The places it checks are:

	CommitMap 	--> This indicates if the entry made it into the processlist within the last 4 hrs
	Last PL		--> Check if still in a processList
	Holding 	--> See if it is in holding

Returns:
	status 		= Status of reveal from possible ack responses
	commit 		= The commit message

func (*State) GetEntryCommitAckByTXID

func (s *State) GetEntryCommitAckByTXID(hash interfaces.IHash) (status int, blktime interfaces.Timestamp, commit interfaces.IMsg, entryhash interfaces.IHash)

GetEntryCommitAckByTXID will fetch the status of a commit by TxID

Searches this order:
	Database	--> Check if it made it to blockchain
	PL			-->	See if it is still in the processlist
	PL - 1		-->	Only if min 0, because then it's not in DB yet, but still in this PL
	Holding 	--> See if it is in holding

func (*State) GetEntryRevealAckByEntryHash

func (s *State) GetEntryRevealAckByEntryHash(hash interfaces.IHash) (status int, blktime interfaces.Timestamp, commit interfaces.IMsg)

GetEntryRevealAck will fetch the status of a entryreveal. The places it checks are:

	ReplayMap	--> This indicates if the entry made it into the processlist within the last 4 hrs
	Database	-->	Check if it made it to blockchain
	Holding		-->	See if it is in holding. Will also look for commit if it finds that

Returns:
	status 		= Status of reveal from possible ack responses
	blktime		= The time of the block if found in the database, nil if not found in blockchain
	commit		 = Only returned if found from holding. This will be empty if found in dbase or in processlist

func (*State) GetEventService

func (s *State) GetEventService() events.EventService

func (*State) GetF

func (s *State) GetF(rt bool, adr [32]byte) (v int64)

GetF() If rt == true, read the Temp balances. Otherwise read the Permanent balances. concurrency safe to call

func (*State) GetFactoidState

func (s *State) GetFactoidState() interfaces.IFactoidState

func (*State) GetFactomNodeName

func (s *State) GetFactomNodeName() string

func (*State) GetFactomdLocations

func (s *State) GetFactomdLocations() string

func (*State) GetFactomdVersion

func (s *State) GetFactomdVersion() string

func (*State) GetFactoshisPerEC

func (s *State) GetFactoshisPerEC() uint64

func (*State) GetFaultTimeout

func (s *State) GetFaultTimeout() int

func (*State) GetFaultWait

func (s *State) GetFaultWait() int

func (*State) GetFedServers

func (s *State) GetFedServers(dbheight uint32) []interfaces.IServer

func (*State) GetHighestAck

func (s *State) GetHighestAck() uint32

func (*State) GetHighestCompletedBlk

func (s *State) GetHighestCompletedBlk() uint32

This is the highest block signed off, but not necessarily validated.

func (*State) GetHighestKnownBlock

func (s *State) GetHighestKnownBlock() uint32

The highest block for which we have received a message. Sometimes the same as BuildingBlock(), but can be different depending or the order messages are received.

func (*State) GetHighestLockedSignedAndSavesBlk

func (s *State) GetHighestLockedSignedAndSavesBlk() uint32

func (*State) GetHighestSavedBlk

func (s *State) GetHighestSavedBlk() uint32

This is the highest block signed off and recorded in the Database.

func (*State) GetIdentityChainID

func (s *State) GetIdentityChainID() (rval interfaces.IHash)

func (*State) GetIgnoreDone

func (s *State) GetIgnoreDone() bool

func (*State) GetInputRegEx

func (s *State) GetInputRegEx() (*regexp.Regexp, string)

func (*State) GetInvalidMsg

func (s *State) GetInvalidMsg(hash interfaces.IHash) interfaces.IMsg

func (*State) GetJournalMessages

func (s *State) GetJournalMessages() [][]byte

GetJournalMessages gets all messages from the message journal

func (*State) GetLLeaderHeight

func (s *State) GetLLeaderHeight() uint32

func (*State) GetLastStatus

func (s *State) GetLastStatus() string

func (*State) GetLeaderHeight

func (s *State) GetLeaderHeight() uint32

This is lowest block currently under construction under the "leader".

func (*State) GetLeaderPL

func (s *State) GetLeaderPL() interfaces.IProcessList

GetLeaderPL returns the leader process list from the state. this method is for debugging and should not be called in normal production code.

func (*State) GetLeaderTimestamp

func (s *State) GetLeaderTimestamp() interfaces.Timestamp

func (*State) GetLeaderVM

func (s *State) GetLeaderVM() int

func (*State) GetMatryoshka

func (s *State) GetMatryoshka(dbheight uint32) (rval interfaces.IHash)

func (*State) GetMessageFilterTimestamp

func (s *State) GetMessageFilterTimestamp() interfaces.Timestamp

func (*State) GetMessageTalliesReceived

func (s *State) GetMessageTalliesReceived(i int) int

func (*State) GetMessageTalliesSent

func (s *State) GetMessageTalliesSent(i int) int

func (*State) GetMinuteDuration

func (s *State) GetMinuteDuration() time.Duration

func (*State) GetMissingDBState

func (s *State) GetMissingDBState(height uint32) error

func (*State) GetMissingEntryCount

func (s *State) GetMissingEntryCount() uint32

func (*State) GetMsg

func (s *State) GetMsg(vmIndex int, dbheight int, height int) (interfaces.IMsg, error)

func (*State) GetNetStateOff

func (s *State) GetNetStateOff() bool

func (*State) GetNetworkBootStrapIdentity

func (s *State) GetNetworkBootStrapIdentity() (rval interfaces.IHash)

The initial identity that can sign the first block

func (*State) GetNetworkBootStrapKey

func (s *State) GetNetworkBootStrapKey() (rval interfaces.IHash)

The initial public key that can sign the first block

func (*State) GetNetworkID

func (s *State) GetNetworkID() uint32

func (*State) GetNetworkIdentityRegistrationChain

func (s *State) GetNetworkIdentityRegistrationChain() (rval interfaces.IHash)

func (*State) GetNetworkName

func (s *State) GetNetworkName() string

func (*State) GetNetworkNumber

func (s *State) GetNetworkNumber() int

func (*State) GetNetworkSkeletonIdentity

func (s *State) GetNetworkSkeletonIdentity() (rval interfaces.IHash)

The identity for validating messages

func (*State) GetNetworkSkeletonKey

func (st *State) GetNetworkSkeletonKey() (rval interfaces.IHash)

func (*State) GetNewEBlocks

func (s *State) GetNewEBlocks(dbheight uint32, hash interfaces.IHash) interfaces.IEntryBlock

func (*State) GetNewHash

func (s *State) GetNewHash() (rval interfaces.IHash)

func (*State) GetOnlineAuditServers

func (s *State) GetOnlineAuditServers(dbheight uint32) []interfaces.IServer

func (*State) GetOut

func (s *State) GetOut() bool

func (*State) GetOutputRegEx

func (s *State) GetOutputRegEx() (*regexp.Regexp, string)

func (*State) GetPendingEntries

func (s *State) GetPendingEntries(params interface{}) []interfaces.IPendingEntry

func (*State) GetPendingTransactions

func (s *State) GetPendingTransactions(params string) []interfaces.IPendingTransaction

GetPendingTransactions returns a list of transactions that will be included in the upcoming or future blocks

func (*State) GetPort

func (s *State) GetPort() int

func (*State) GetPredictiveFER

func (this *State) GetPredictiveFER() uint64

Returns the higher of the current factoid exchange rate and what it knows will change in the future

func (*State) GetPreviousMinuteStartTime

func (s *State) GetPreviousMinuteStartTime() int64

func (*State) GetRpcAuthHash

func (s *State) GetRpcAuthHash() []byte

func (*State) GetRpcPass

func (s *State) GetRpcPass() string

func (*State) GetRpcUser

func (s *State) GetRpcUser() string

func (*State) GetRunState

func (s *State) GetRunState() runstate.RunState

func (*State) GetSalt

func (s *State) GetSalt(ts interfaces.Timestamp) uint32

func (*State) GetServerPrivateKey

func (s *State) GetServerPrivateKey() *primitives.PrivateKey

func (*State) GetServerPublicKey

func (s *State) GetServerPublicKey() *primitives.PublicKey

func (*State) GetServerPublicKeyString

func (s *State) GetServerPublicKeyString() string

func (*State) GetSigningKey

func (st *State) GetSigningKey(id interfaces.IHash) (interfaces.IHash, int)

GetSigningKey will return the signing key of the identity, and it's type

Returns:
	-1	--> Follower
	0 	--> Audit Server
	1	--> Federated

func (*State) GetSpecificACKStatus

func (s *State) GetSpecificACKStatus(hash interfaces.IHash) (int, interfaces.IHash, interfaces.Timestamp, interfaces.Timestamp, error)

GetSpecificACKStatus does NOT check the oldmsgs map. This is because the processlists map for entries and entry blocks is updated after the oldmsgs. This means an EntryACK will returns TransactionACK, but GetChain will return not found To fix this, for some calls (entries) we don't want to check the oldmsgs.

func (*State) GetStatus

func (s *State) GetStatus() []string

func (*State) GetSystemHeight

func (s *State) GetSystemHeight(dbheight uint32) int

func (*State) GetSystemMsg

func (s *State) GetSystemMsg(dbheight uint32, height uint32) interfaces.IMsg

Gets the system message at the given dbheight, and given height in the System list

func (*State) GetTimeOffset

func (s *State) GetTimeOffset() interfaces.Timestamp

func (*State) GetTimestamp

func (s *State) GetTimestamp() interfaces.Timestamp

Returns a millisecond timestamp

func (*State) GetTlsInfo

func (s *State) GetTlsInfo() (bool, string, string)

func (*State) GetTrueLeaderHeight

func (s *State) GetTrueLeaderHeight() uint32

returns what finished block height this node thinks the leader is at, assuming that the local node has the process list the leader is working on plus an extra empty one on top of it.

func (*State) GetUnsyncedServers

func (s *State) GetUnsyncedServers() (ids []interfaces.IHash, vms []int)

GetUnsyncedServers returns an array of the IDs for all unsynced VMs when you are not in a sync phase, no VM is considered sync'd

func (*State) GetUnsyncedServersString

func (s *State) GetUnsyncedServersString() string

GetUnsyncedServersString returns a string with the short IDs for all unsynced VMs

func (*State) GetVirtualServers

func (s *State) GetVirtualServers(dbheight uint32, minute int, identityChainID interfaces.IHash) (bool, int)

func (*State) GotHeartbeat

func (s *State) GotHeartbeat(heartbeatTS interfaces.Timestamp, dbheight uint32)

func (*State) HoldForHeight

func (s *State) HoldForHeight(ht uint32, minute int, msg interfaces.IMsg) int

func (*State) HookLogstash

func (s *State) HookLogstash() error

func (*State) InMsgQueue

func (s *State) InMsgQueue() interfaces.IQueue

func (*State) InMsgQueue2

func (s *State) InMsgQueue2() interfaces.IQueue

func (*State) IncDBStateAnswerCnt

func (s *State) IncDBStateAnswerCnt()

func (*State) IncECCommits

func (s *State) IncECCommits()

func (*State) IncECommits

func (s *State) IncECommits()

func (*State) IncEntries

func (s *State) IncEntries()

func (*State) IncEntryChains

func (s *State) IncEntryChains()

func (*State) IncFCTSubmits

func (s *State) IncFCTSubmits()

func (*State) IncFactoidTrans

func (s *State) IncFactoidTrans()

func (*State) Init

func (s *State) Init()

func (*State) InitBoltDB

func (s *State) InitBoltDB() error

func (*State) InitLevelDB

func (s *State) InitLevelDB() error

func (*State) InitMapDB

func (s *State) InitMapDB() error

func (*State) InitiateNetworkIdentityRegistration

func (st *State) InitiateNetworkIdentityRegistration() error

func (*State) IntiateNetworkSkeletonIdentity

func (st *State) IntiateNetworkSkeletonIdentity() error

Add the skeleton identity and try to build it

func (*State) IsActive

func (s *State) IsActive(id activations.ActivationType) bool

Return if a feature is active for the current height

func (*State) IsHighestCommit

func (s *State) IsHighestCommit(hash interfaces.IHash, msg interfaces.IMsg) bool

IsHighestCommit will determine if the commit given has more entry credits than the current commit in the commit hashmap. If there is no prior commit, this will also return true.

func (*State) IsLeader

func (s *State) IsLeader() bool

func (*State) IsNewOrPendingEBlocks

func (s *State) IsNewOrPendingEBlocks(dbheight uint32, hash interfaces.IHash) bool

func (*State) IsRunLeader

func (s *State) IsRunLeader() bool

func (*State) IsStalled

func (s *State) IsStalled() bool

func (*State) IsStateFullySynced

func (s *State) IsStateFullySynced() bool

func (*State) IsSyncing

func (s *State) IsSyncing() bool

func (*State) IsSyncingDBSigs

func (s *State) IsSyncingDBSigs() bool

func (*State) IsSyncingEOMs

func (s *State) IsSyncingEOMs() bool

func (*State) JournalMessage

func (s *State) JournalMessage(msg interfaces.IMsg)

JournalMessage writes the message to the message journal for debugging

func (*State) LeaderExecute

func (s *State) LeaderExecute(m interfaces.IMsg)

func (*State) LeaderExecuteCommitChain

func (s *State) LeaderExecuteCommitChain(m interfaces.IMsg)

func (*State) LeaderExecuteCommitEntry

func (s *State) LeaderExecuteCommitEntry(m interfaces.IMsg)

func (*State) LeaderExecuteDBSig

func (s *State) LeaderExecuteDBSig(m interfaces.IMsg)

func (*State) LeaderExecuteEOM

func (s *State) LeaderExecuteEOM(m interfaces.IMsg)

func (*State) LeaderExecuteRevealEntry

func (s *State) LeaderExecuteRevealEntry(m interfaces.IMsg)

func (*State) LoadAcksMap

func (s *State) LoadAcksMap() map[[32]byte]interfaces.IMsg

this is called from the APIs that do not have access directly to the Acks. State makes a copy and puts it in AcksMap

func (*State) LoadConfig

func (s *State) LoadConfig(filename string, networkFlag string)

func (*State) LoadDBState

func (s *State) LoadDBState(dbheight uint32) (interfaces.IMsg, error)

func (*State) LoadDataByHash

func (s *State) LoadDataByHash(requestedHash interfaces.IHash) (interfaces.BinaryMarshallable, int, error)

func (*State) LoadHoldingMap

func (s *State) LoadHoldingMap() map[[32]byte]interfaces.IMsg

func (*State) LoadIdentityByEntry

func (st *State) LoadIdentityByEntry(ent interfaces.IEBEntry, height uint32, dblockTimestamp interfaces.Timestamp, d *DBState)

LoadIdentityByEntry is only useful when initial is set to false. If initial is false, it will track changes in an identity that corresponds to an authority. If initial is true, then calling ProcessIdentityEntry directly will have the same result.

func (*State) LoadSpecificMsg

func (s *State) LoadSpecificMsg(dbheight uint32, vm int, plistheight uint32) (interfaces.IMsg, error)

func (*State) LoadSpecificMsgAndAck

func (s *State) LoadSpecificMsgAndAck(dbheight uint32, vmIndex int, plistheight uint32) (interfaces.IMsg, interfaces.IMsg, error)

func (*State) Log

func (s *State) Log(level string, message string)

func (*State) LogMessage

func (s *State) LogMessage(logName string, comment string, msg interfaces.IMsg)

func (*State) LogPrintf

func (s *State) LogPrintf(logName string, format string, more ...interface{})

func (*State) Logf

func (s *State) Logf(level string, format string, args ...interface{})

func (*State) LookupIdentityInBlockchainByChainID

func (st *State) LookupIdentityInBlockchainByChainID(cid interfaces.IHash) error

func (*State) MMRDummy

func (s *State) MMRDummy()

MMRDummy is for unit tests that populate the various mmr queues. We need to drain the queues to ensure we don't block.

ONLY FOR UNIT TESTS

func (*State) MoveStateToHeight

func (s *State) MoveStateToHeight(dbheight uint32, newMinute int)

func (*State) MsgQueue

func (s *State) MsgQueue() chan interfaces.IMsg

func (*State) Needed

func (s *State) Needed(eb interfaces.IEntryBlock) bool

Checks ChainIDs to determine if we need their entries to process entries and transactions.

func (*State) NetworkInvalidMsgQueue

func (s *State) NetworkInvalidMsgQueue() chan interfaces.IMsg

func (*State) NetworkOutMsgQueue

func (s *State) NetworkOutMsgQueue() interfaces.IQueue

func (*State) NewAck

func (s *State) NewAck(msg interfaces.IMsg, balanceHash interfaces.IHash) interfaces.IMsg

Create a new Acknowledgement. Must be called by a leader. This call assumes all the pieces are in place to create a new acknowledgement

func (*State) NextCommit

func (s *State) NextCommit(hash interfaces.IHash) interfaces.IMsg

Returns the oldest, not processed, Commit received

func (*State) NoEntryYet

func (s *State) NoEntryYet(entryhash interfaces.IHash, ts interfaces.Timestamp) bool

Returns true if this hash exists nowhere in the Replay structures. Returns False if we have already seen this hash before. Replay is NOT updated yet.

func (*State) PassInputRegEx

func (s *State) PassInputRegEx(RegEx *regexp.Regexp, RegExString string)

func (*State) PassOutputRegEx

func (s *State) PassOutputRegEx(RegEx *regexp.Regexp, RegExString string)

func (*State) Print

func (s *State) Print(a ...interface{}) (n int, err error)

func (*State) Println

func (s *State) Println(a ...interface{}) (n int, err error)

func (*State) PrioritizedMsgQueue

func (s *State) PrioritizedMsgQueue() chan interfaces.IMsg

func (*State) Process

func (s *State) Process() (progress bool)

func (*State) ProcessAddServer

func (s *State) ProcessAddServer(dbheight uint32, addServerMsg interfaces.IMsg) bool

func (*State) ProcessChangeServerKey

func (s *State) ProcessChangeServerKey(dbheight uint32, changeServerKeyMsg interfaces.IMsg) bool

func (*State) ProcessCommitChain

func (s *State) ProcessCommitChain(dbheight uint32, commitChain interfaces.IMsg) bool

func (*State) ProcessCommitEntry

func (s *State) ProcessCommitEntry(dbheight uint32, commitEntry interfaces.IMsg) bool

func (*State) ProcessDBSig

func (s *State) ProcessDBSig(dbheight uint32, msg interfaces.IMsg) bool

When we process the directory Signature, and we are the leader for said signature, it is then that we push it out to the rest of the network. Otherwise, if we are not the leader for the signature, it marks the sig complete for that list

func (*State) ProcessEOM

func (s *State) ProcessEOM(dbheight uint32, msg interfaces.IMsg) bool

TODO: Should fault the server if we don't have the proper sequence of EOM messages.

func (*State) ProcessInvalidMsgQueue

func (s *State) ProcessInvalidMsgQueue()

func (*State) ProcessRecentFERChainEntries

func (this *State) ProcessRecentFERChainEntries()

Go through the factoid exchange rate chain and determine if an FER change should be scheduled

func (*State) ProcessRemoveServer

func (s *State) ProcessRemoveServer(dbheight uint32, removeServerMsg interfaces.IMsg) bool

func (*State) ProcessRevealEntry

func (s *State) ProcessRevealEntry(dbheight uint32, m interfaces.IMsg) (worked bool)

func (*State) PutCommit

func (s *State) PutCommit(hash interfaces.IHash, msg interfaces.IMsg)

func (*State) PutE

func (s *State) PutE(rt bool, adr [32]byte, v int64)

PutE() If rt == true, update the Temp balances. Otherwise update the Permanent balances. concurrency safe to call

func (*State) PutF

func (s *State) PutF(rt bool, adr [32]byte, v int64)

PutF() If rt == true, update the Temp balances. Otherwise update the Permanent balances. concurrency safe to call

func (*State) PutNewEBlocks

func (s *State) PutNewEBlocks(dbheight uint32, hash interfaces.IHash, eb interfaces.IEntryBlock)

func (*State) PutNewEntries

func (s *State) PutNewEntries(dbheight uint32, hash interfaces.IHash, e interfaces.IEntry)

func (*State) ReadCfg

func (s *State) ReadCfg(filename string) interfaces.IFactomConfig

ReadCfg forces a read of the Factom config file. However, it does not change the state of any cfg object held by other processes... Only what will be returned by future calls to Cfg().(s.Cfg.(*util.FactomdConfig)).String()

func (*State) RemoveAuditServer

func (s *State) RemoveAuditServer(dbheight uint32, hash interfaces.IHash)

func (*State) RemoveFedServer

func (s *State) RemoveFedServer(dbheight uint32, hash interfaces.IHash)

func (*State) RepairAuthorities

func (s *State) RepairAuthorities()

RepairAuthorities will put the management chain of an identity in the authority if it is missing.

func (*State) Reset

func (s *State) Reset()

func (*State) ReviewHolding

func (s *State) ReviewHolding()

Places the entries in the holding map back into the XReview list for review if this is a leader, and those messages are that leader's responsibility

func (*State) RunUploadController

func (s *State) RunUploadController()

func (*State) SendDBSig

func (s *State) SendDBSig(dbheight uint32, vmIndex int)

dbheight is the height of the process list, and vmIndex is the vm that is missing the DBSig. If the DBSig isn't our responsibility, then this call will do nothing. Assumes the state for the leader is set properly

func (*State) SendHeartBeat

func (s *State) SendHeartBeat()

func (*State) SetAuthoritySetString

func (s *State) SetAuthoritySetString(authSet string)

func (*State) SetDBStateManagerCompletedHeight

func (s *State) SetDBStateManagerCompletedHeight(height uint32) error

func (*State) SetDBStatesSent

func (s *State) SetDBStatesSent(sents []*interfaces.DBStateSent)

func (*State) SetDelay

func (s *State) SetDelay(delay int64)

func (*State) SetDirectoryBlockInSeconds

func (s *State) SetDirectoryBlockInSeconds(t int)

func (*State) SetDropRate

func (s *State) SetDropRate(droprate int)

func (*State) SetEntryBlockDBHeightComplete

func (s *State) SetEntryBlockDBHeightComplete(newHeight uint32)

func (*State) SetEntryBlockDBHeightProcessing

func (s *State) SetEntryBlockDBHeightProcessing(newHeight uint32)

func (*State) SetFactoidState

func (s *State) SetFactoidState(dbheight uint32, fs interfaces.IFactoidState)

func (*State) SetFactoshisPerEC

func (s *State) SetFactoshisPerEC(factoshisPerEC uint64)

func (*State) SetFaultTimeout

func (s *State) SetFaultTimeout(timeout int)

func (*State) SetFaultWait

func (s *State) SetFaultWait(wait int)

func (*State) SetHighestAck

func (s *State) SetHighestAck(dbht uint32)

func (*State) SetHighestKnownBlock

func (s *State) SetHighestKnownBlock(dbht uint32)

func (*State) SetIdentityChainID

func (s *State) SetIdentityChainID(chainID interfaces.IHash)

func (*State) SetIsDoneReplaying

func (s *State) SetIsDoneReplaying()

func (*State) SetIsReplaying

func (s *State) SetIsReplaying()

func (*State) SetLeaderTimestamp

func (s *State) SetLeaderTimestamp(ts interfaces.Timestamp)

func (*State) SetMessageFilterTimestamp

func (s *State) SetMessageFilterTimestamp(requestedTS interfaces.Timestamp)

the MessageFilterTimestamp is used to filter messages from the past or before the replay filter. We will not set it to a time that is before (20 minutes before) boot or more than one hour in the past. this ensure messages from prior boot and messages that predate the current replay filter are are dropped. It marks the start of the replay filter content

func (*State) SetNetStateOff

func (s *State) SetNetStateOff(net bool)

func (*State) SetOut

func (s *State) SetOut(o bool)

func (*State) SetPendingSigningKey

func (s *State) SetPendingSigningKey(p *primitives.PrivateKey)

func (*State) SetPort

func (s *State) SetPort(port int)

Allow us the ability to update the port number at run time....

func (*State) SetRpcAuthHash

func (s *State) SetRpcAuthHash(authHash []byte)

func (*State) SetString

func (s *State) SetString()

func (*State) SetStringConsensus

func (s *State) SetStringConsensus()

func (*State) SetStringQueues

func (s *State) SetStringQueues()

func (*State) SetTorrentUploader

func (s *State) SetTorrentUploader(setVal bool)

Only called once to set the torrent flag.

func (*State) SetUseTorrent

func (s *State) SetUseTorrent(setVal bool)

Only called once to set the torrent flag.

func (*State) SetupCrossBootReplay

func (s *State) SetupCrossBootReplay(path string)

SetupCrossBootReplay will construct the database

func (*State) ShortString

func (s *State) ShortString() string

func (*State) ShutdownNode

func (s *State) ShutdownNode(exitCode int)

func (*State) Sign

func (s *State) Sign(b []byte) interfaces.IFullSignature

func (*State) SimGetSigKey

func (s *State) SimGetSigKey() string

func (*State) SimSetNewKeys

func (s *State) SimSetNewKeys(p *primitives.PrivateKey)

func (*State) StartMMR

func (s *State) StartMMR()

starts the MMR processing for this state

func (*State) StartTorrentSyncing

func (s *State) StartTorrentSyncing() error

StartTorrentSyncing is an endless loop that uses torrents to sync missing blocks It will grab any block higher than the highest dblock saved in the database up to the highest known block.

func (*State) String

func (s *State) String() string

func (*State) SummaryHeader

func (s *State) SummaryHeader() string

func (*State) SyncIdentities

func (st *State) SyncIdentities(d *DBState)

SyncIdentities will run through the identities and sync any identities that need to be updated. If the current height is equal to the eblock+1, then this entry can trigger a change in key to the admin block

func (*State) TallyReceived

func (s *State) TallyReceived(msgType int)

func (*State) TallySent

func (s *State) TallySent(msgType int)

func (*State) TickerQueue

func (s *State) TickerQueue() chan int

func (*State) TimerMsgQueue

func (s *State) TimerMsgQueue() chan interfaces.IMsg

func (*State) TorrentUploader

func (s *State) TorrentUploader() bool

func (*State) TrimVMList

func (s *State) TrimVMList(dbheight uint32, height uint32, vmIndex int)

func (*State) UpdateAuthSigningKeys

func (st *State) UpdateAuthSigningKeys(height uint32)

We keep a 2 block history of their keys, this is so if we change their key and need to verify a message from 1 block ago, we still can. This function garbage collects old keys

func (*State) UpdateAuthorityFromABEntry

func (st *State) UpdateAuthorityFromABEntry(entry interfaces.IABEntry) error

func (*State) UpdateECs

func (s *State) UpdateECs(ec interfaces.IEntryCreditBlock)

func (*State) UpdateState

func (s *State) UpdateState() (progress bool)

func (*State) UploadDBState

func (s *State) UploadDBState(dbheight uint32)

All calls get sent here and redirected into the uploadcontroller queue.

func (*State) UsingTorrent

func (s *State) UsingTorrent() bool

func (*State) Validate

func (s *State) Validate(msg interfaces.IMsg) (validToSend int, validToExec int)

this is the common validation to all messages. they must not be a reply, they must not be out size the time window for the replay filter.

func (*State) ValidatePrevious

func (s *State) ValidatePrevious(dbheight uint32) error

func (*State) ValidatorLoop

func (s *State) ValidatorLoop()

func (*State) VerifyAuthoritySignature

func (st *State) VerifyAuthoritySignature(msg []byte, sig *[constants.SIGNATURE_LENGTH]byte, dbheight uint32) (rval int, err error)

Checks the signature of a message. Returns an int based on who signed it:

1  -> Federated Signature
0  -> Audit Signature
-1 -> Neither Fed or Audit Signature

func (*State) VerifyIsAuthority

func (st *State) VerifyIsAuthority(cid interfaces.IHash) bool

Verifies if is authority

Return true if authority, false if not

func (*State) WriteEntries

func (s *State) WriteEntries()

WriteEntries consumed the WriteEntry channel and saves entries into the database. Assumes entries are valid. Panics on database errors

type StateSaverStruct

type StateSaverStruct struct {
	FastBoot         bool
	FastBootLocation string

	TmpDBHt  uint32
	TmpState []byte
	Mutex    sync.Mutex
	Stop     bool
}

func (*StateSaverStruct) DeleteSaveState

func (sss *StateSaverStruct) DeleteSaveState(networkName string) error

func (*StateSaverStruct) LoadDBStateList

func (sss *StateSaverStruct) LoadDBStateList(s *State, statelist *DBStateList, networkName string) error

func (*StateSaverStruct) SaveDBStateList

func (sss *StateSaverStruct) SaveDBStateList(s *State, ss *DBStateList, networkName string) error

func (*StateSaverStruct) StopSaving

func (sss *StateSaverStruct) StopSaving()

type StatesMissing

type StatesMissing struct {
	List *list.List
	// contains filtered or unexported fields
}

func NewStatesMissing

func NewStatesMissing() *StatesMissing

NewStatesMissing creates a new list of missing DBStates.

func (*StatesMissing) Add

func (l *StatesMissing) Add(height uint32)

Add adds a new MissingState to the list.

func (*StatesMissing) DeleteLockless

func (l *StatesMissing) DeleteLockless(height uint32)

func (*StatesMissing) Get

func (l *StatesMissing) Get(height uint32) *MissingState

func (*StatesMissing) GetFront

func (l *StatesMissing) GetFront() *MissingState

func (*StatesMissing) GetNext

func (l *StatesMissing) GetNext() *MissingState

GetNext pops the next MissingState from the list.

func (*StatesMissing) Len

func (l *StatesMissing) Len() int

func (*StatesMissing) LockAndDelete

func (l *StatesMissing) LockAndDelete(height uint32)

LockAndDelete removes a MissingState from the list.

func (*StatesMissing) NextConsecutiveMissing

func (l *StatesMissing) NextConsecutiveMissing(n int) (uint32, uint32)

NextConsecutiveMissing returns the heights of the the next n or fewer consecutive missing states

type StatesReceived

type StatesReceived struct {
	List   *list.List
	Notify chan *messages.DBStateMsg
	// contains filtered or unexported fields
}

StatesReceived is the list of DBStates received from the network. "base" represents the height of known saved states.

func NewStatesReceived

func NewStatesReceived() *StatesReceived

func (*StatesReceived) Add

func (l *StatesReceived) Add(height uint32, msg *messages.DBStateMsg)

Add adds a new received state to the list.

func (*StatesReceived) Base

func (l *StatesReceived) Base() uint32

Base returns the base height of the StatesReceived list

func (*StatesReceived) Get

func (l *StatesReceived) Get(height uint32) *ReceivedState

Get returns a member from the StatesReceived list

func (*StatesReceived) GetNext

func (l *StatesReceived) GetNext() *ReceivedState

func (*StatesReceived) Has

func (l *StatesReceived) Has(height uint32) bool

func (*StatesReceived) Heighestreceived

func (l *StatesReceived) Heighestreceived() uint32

Heighestreceived returns the height of the last member in StatesReceived

func (*StatesReceived) ListAsSlice

func (l *StatesReceived) ListAsSlice() []uint32

ListAsSlice will return the list as a slice to be iterated over in a threadsafe manner.

func (*StatesReceived) LockAndDelete

func (l *StatesReceived) LockAndDelete(height uint32)

LockAndDelete removes a state from the StatesReceived list

func (*StatesReceived) SetBase

func (l *StatesReceived) SetBase(height uint32)

func (*StatesReceived) SetBaseLockless

func (l *StatesReceived) SetBaseLockless(height uint32)

type StatesWaiting

type StatesWaiting struct {
	List *list.List
	// contains filtered or unexported fields
}

func NewStatesWaiting

func NewStatesWaiting() *StatesWaiting

func (*StatesWaiting) Add

func (l *StatesWaiting) Add(height uint32)

func (*StatesWaiting) Get

func (l *StatesWaiting) Get(height uint32) *WaitingState

func (*StatesWaiting) GetEnd

func (l *StatesWaiting) GetEnd() *WaitingState

func (*StatesWaiting) Has

func (l *StatesWaiting) Has(height uint32) bool

func (*StatesWaiting) Len

func (l *StatesWaiting) Len() int

func (*StatesWaiting) ListAsSlice

func (l *StatesWaiting) ListAsSlice() []*WaitingState

func (*StatesWaiting) LockAndDelete

func (l *StatesWaiting) LockAndDelete(height uint32)

type UploadController

type UploadController struct {
	DBStateManager interfaces.IManagerController
	// contains filtered or unexported fields
}

Controls the flow of uploading torrents

func (*UploadController) Close

func (u *UploadController) Close()

type VM

type VM struct {
	List            []interfaces.IMsg // Lists of acknowledged messages
	ListAck         []*messages.Ack   // Acknowledgements
	Height          int               // Height of first unprocessed message (count of messages processed)
	EomMinuteIssued int               // Last Minute Issued on this VM (from the leader, when we are the leader)
	LeaderMinute    int               // Where the leader is in acknowledging messages
	Synced          bool              // Is this VM synced yet?

	Signed      bool                 // We have signed the previous block.
	WhenFaulted int64                // WhenFaulted is a timestamp of when this VM was faulted
	FaultFlag   int                  // FaultFlag tracks what the VM was faulted for (0 = EOM missing, 1 = negotiation issue)
	ProcessTime interfaces.Timestamp // Last time we made progress on this VM
	VmIndex     int                  // the index of this MV
	HighestNil  int                  // Debug highest nil reported
	// contains filtered or unexported fields
}

func (*VM) ReportMissing

func (vm *VM) ReportMissing(height int, delay int64)

Ask VM for an MMR for this height with delay ms before asking the network called from validation thread to notify MMR that we are missing a message

type WaitingState

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

func NewWaitingState

func NewWaitingState(height uint32) *WaitingState

func (*WaitingState) Height

func (s *WaitingState) Height() uint32

func (*WaitingState) RequestAge

func (s *WaitingState) RequestAge() time.Duration

func (*WaitingState) ResetRequestAge

func (s *WaitingState) ResetRequestAge()

type WholeBlock

type WholeBlock struct {
	// Header and entry headers
	DBlock interfaces.IDirectoryBlock

	// Block and admin block entries
	ABlock interfaces.IAdminBlock

	// Block and transactions
	FBlock interfaces.IFBlock

	// Block and entries
	ECBlock interfaces.IEntryCreditBlock

	EBlocks []interfaces.IEntryBlock

	Entries []interfaces.IEBEntry

	SigList []interfaces.IFullSignature
}

func NewWholeBlock

func NewWholeBlock() *WholeBlock

func ReadDBStateFromDebugFile

func ReadDBStateFromDebugFile(filename string) (*WholeBlock, error)

func (*WholeBlock) AddEblock

func (wb *WholeBlock) AddEblock(eb interfaces.IEntryBlock)

func (*WholeBlock) AddEntry

func (wb *WholeBlock) AddEntry(e interfaces.IEntry)

func (*WholeBlock) AddIEBEntry

func (wb *WholeBlock) AddIEBEntry(e interfaces.IEBEntry)

func (*WholeBlock) BlockToDBStateMsg

func (wb *WholeBlock) BlockToDBStateMsg() interfaces.IMsg

func (*WholeBlock) IsSameAs

func (a *WholeBlock) IsSameAs(b *WholeBlock) (resp bool)

func (*WholeBlock) MarshalBinary

func (wb *WholeBlock) MarshalBinary() (b []byte, err error)

func (*WholeBlock) UnmarshalBinary

func (wb *WholeBlock) UnmarshalBinary(data []byte) (err error)

func (*WholeBlock) UnmarshalBinaryData

func (wb *WholeBlock) UnmarshalBinaryData(data []byte) (newData []byte, err error)

func (*WholeBlock) UnmarshalBinaryDataBuffer

func (wb *WholeBlock) UnmarshalBinaryDataBuffer(buffer io.ReadSeeker, whence int) (read int64, err error)

Jump to

Keyboard shortcuts

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