interfaces

package
v0.0.0-...-37d5065 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 8 Imported by: 46

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryMarshallable

type BinaryMarshallable interface {
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler

	UnmarshalBinaryData([]byte) ([]byte, error)
}

type BinaryMarshallableAndCopyable

type BinaryMarshallableAndCopyable interface {
	BinaryMarshallable
	New() BinaryMarshallableAndCopyable
}

type DBOverlay

type DBOverlay interface {
	// We let Database method calls flow through.
	IDatabase

	FetchHeadIndexByChainID(chainID IHash) (IHash, error)
	SetExportData(path string)

	StartMultiBatch()
	PutInMultiBatch(records []Record)
	ExecuteMultiBatch() error
	GetEntryType(hash IHash) (IHash, error)

	// InsertEntry inserts an entry
	InsertEntry(entry IEBEntry) (err error)
	InsertEntryMultiBatch(entry IEBEntry) error

	// FetchEntry gets an entry by hash from the database.
	FetchEntry(IHash) (IEBEntry, error)

	FetchAllEntriesByChainID(chainID IHash) ([]IEBEntry, error)

	FetchAllEntryIDsByChainID(chainID IHash) ([]IHash, error)

	FetchAllEntryIDs() ([]IHash, error)

	// ProcessEBlockBatche inserts the EBlock and update all it's ebentries in DB
	ProcessEBlockBatch(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessEBlockBatchWithoutHead(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessEBlockMultiBatchWithoutHead(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessEBlockMultiBatch(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error

	FetchEBlock(IHash) (IEntryBlock, error)

	// FetchEBlockByHash gets an entry by hash from the database.
	FetchEBlockByPrimary(IHash) (IEntryBlock, error)

	// FetchEBlockByKeyMR gets an entry by hash from the database.
	FetchEBlockBySecondary(hash IHash) (IEntryBlock, error)

	// FetchEBKeyMRByHash gets an entry by hash from the database.
	FetchEBKeyMRByHash(hash IHash) (IHash, error)

	// FetchAllEBlocksByChain gets all of the blocks by chain id
	FetchAllEBlocksByChain(IHash) ([]IEntryBlock, error)

	SaveEBlockHead(block DatabaseBlockWithEntries, checkForDuplicateEntries bool) error

	FetchEBlockHead(chainID IHash) (IEntryBlock, error)

	FetchAllEBlockChainIDs() ([]IHash, error)

	// ProcessDBlockBatche inserts the EBlock and update all it's ebentries in DB
	ProcessDBlockBatch(block DatabaseBlockWithEntries) error
	ProcessDBlockBatchWithoutHead(block DatabaseBlockWithEntries) error
	ProcessDBlockMultiBatch(block DatabaseBlockWithEntries) error

	// FetchHeightRange looks up a range of blocks by the start and ending
	// heights.  Fetch is inclusive of the start height and exclusive of the
	// ending height. To fetch all hashes from the start height until no
	// more are present, use -1 as endHeight.
	FetchDBlockHeightRange(startHeight, endHeight int64) ([]IHash, error)

	// FetchBlockHeightByKeyMR returns the block height for the given hash.  This is
	// part of the database.Db interface implementation.
	FetchDBlockHeightByKeyMR(IHash) (int64, error)

	FetchDBlock(IHash) (IDirectoryBlock, error)

	// FetchDBlock gets an entry by hash from the database.
	FetchDBlockByPrimary(IHash) (IDirectoryBlock, error)

	// FetchDBlock gets an entry by hash from the database.
	FetchDBlockBySecondary(IHash) (IDirectoryBlock, error)

	// FetchDBlockByHeight gets an directory block by height from the database.
	FetchDBlockByHeight(uint32) (IDirectoryBlock, error)

	FetchDBlockHead() (IDirectoryBlock, error)

	// FetchDBKeyMRByHeight gets a dBlock KeyMR from the database.
	FetchDBKeyMRByHeight(dBlockHeight uint32) (dBlockKeyMR IHash, err error)

	// FetchDBKeyMRByHash gets a DBlock KeyMR by hash.
	FetchDBKeyMRByHash(hash IHash) (dBlockHash IHash, err error)

	// FetchAllFBInfo gets all of the fbInfo
	FetchAllDBlocks() ([]IDirectoryBlock, error)
	FetchAllDBlockKeys() ([]IHash, error)

	SaveDirectoryBlockHead(DatabaseBlockWithEntries) error

	FetchDirectoryBlockHead() (IDirectoryBlock, error)

	// ProcessECBlockBatch inserts the ECBlock and update all it's ecbentries in DB
	ProcessECBlockBatch(IEntryCreditBlock, bool) (err error)
	ProcessECBlockBatchWithoutHead(IEntryCreditBlock, bool) (err error)
	ProcessECBlockMultiBatch(IEntryCreditBlock, bool) (err error)

	FetchECBlock(IHash) (IEntryCreditBlock, error)

	// FetchECBlockByHash gets an Entry Credit block by hash from the database.
	FetchECBlockByPrimary(IHash) (IEntryCreditBlock, error)

	// FetchECBlockByKeyMR gets an Entry Credit block by hash from the database.
	FetchECBlockBySecondary(hash IHash) (IEntryCreditBlock, error)
	FetchECBlockByHeight(blockHeight uint32) (IEntryCreditBlock, error)

	// FetchAllECBlocks gets all of the entry credit blocks
	FetchAllECBlocks() ([]IEntryCreditBlock, error)
	FetchAllECBlockKeys() ([]IHash, error)

	SaveECBlockHead(IEntryCreditBlock, bool) error

	FetchECBlockHead() (IEntryCreditBlock, error)

	// ProcessABlockBatch inserts the AdminBlock
	ProcessABlockBatch(block DatabaseBatchable) error
	ProcessABlockBatchWithoutHead(block DatabaseBatchable) error
	ProcessABlockMultiBatch(block DatabaseBatchable) error

	FetchABlock(IHash) (IAdminBlock, error)

	// FetchABlockByHash gets an admin block by hash from the database.
	FetchABlockByPrimary(hash IHash) (IAdminBlock, error)

	// FetchABlockByKeyMR gets an admin block by keyMR from the database.
	FetchABlockBySecondary(hash IHash) (IAdminBlock, error)
	FetchABlockByHeight(blockHeight uint32) (IAdminBlock, error)

	// FetchAllABlocks gets all of the admin blocks
	FetchAllABlocks() ([]IAdminBlock, error)
	FetchAllABlockKeys() ([]IHash, error)

	SaveABlockHead(DatabaseBatchable) error

	FetchABlockHead() (IAdminBlock, error)

	// ProcessFBlockBatch inserts the Factoid
	ProcessFBlockBatch(DatabaseBlockWithEntries) error
	ProcessFBlockBatchWithoutHead(DatabaseBlockWithEntries) error
	ProcessFBlockMultiBatch(DatabaseBlockWithEntries) error

	FetchFBlock(IHash) (IFBlock, error)

	// FetchFBlockByHash gets a factoid block by hash from the database.
	FetchFBlockByPrimary(IHash) (IFBlock, error)
	FetchFBlockBySecondary(IHash) (IFBlock, error)
	FetchFBlockByHeight(blockHeight uint32) (IFBlock, error)

	// FetchAllFBlocks gets all of the factoid blocks
	FetchAllFBlocks() ([]IFBlock, error)
	FetchAllFBlockKeys() ([]IHash, error)

	SaveFactoidBlockHead(fblock DatabaseBlockWithEntries) error

	FetchFactoidBlockHead() (IFBlock, error)
	FetchFBlockHead() (IFBlock, error)

	// ProcessDirBlockInfoBatch inserts the dirblock info block
	ProcessDirBlockInfoBatch(block IDirBlockInfo) error

	// FetchDirBlockInfoByHash gets a dirblock info block by hash from the database.
	FetchDirBlockInfoByHash(hash IHash) (IDirBlockInfo, error)

	// FetchDirBlockInfoByKeyMR gets a dirblock info block by keyMR from the database.
	FetchDirBlockInfoByKeyMR(hash IHash) (IDirBlockInfo, error)

	// FetchAllConfirmedDirBlockInfos gets all of the confirmed dirblock info blocks
	FetchAllConfirmedDirBlockInfos() ([]IDirBlockInfo, error)

	// FetchAllUnconfirmedDirBlockInfos gets all of the unconfirmed dirblock info blocks
	FetchAllUnconfirmedDirBlockInfos() ([]IDirBlockInfo, error)

	// FetchAllDirBlockInfos gets all of the dirblock info blocks
	FetchAllDirBlockInfos() ([]IDirBlockInfo, error)

	SaveDirBlockInfo(block IDirBlockInfo) error

	SaveIncludedIn(entry, block IHash) error
	SaveIncludedInMultiFromBlock(block DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	SaveIncludedInMulti(entries []IHash, block IHash, checkForDuplicateEntries bool) error
	FetchIncludedIn(hash IHash) (IHash, error)

	ReparseAnchorChains() error
	SetBitcoinAnchorRecordPublicKeysFromHex([]string) error
	SetEthereumAnchorRecordPublicKeysFromHex([]string) error

	FetchPaidFor(hash IHash) (IHash, error)

	FetchFactoidTransaction(hash IHash) (ITransaction, error)
	FetchECTransaction(hash IHash) (IECBlockEntry, error)

	//******************************KeyValueStore**********************************//
	SaveKeyValueStore(kvs BinaryMarshallable, key []byte) error
	FetchKeyValueStore(key []byte, dst BinaryMarshallable) (BinaryMarshallable, error)
	SaveDatabaseEntryHeight(height uint32) error
	FetchDatabaseEntryHeight() (uint32, error)
}

Db defines a generic interface that is used to request and insert data into db

type DBOverlaySimple

type DBOverlaySimple interface {
	Close() error
	DoesKeyExist(bucket, key []byte) (bool, error)
	ExecuteMultiBatch() error
	FetchABlock(IHash) (IAdminBlock, error)
	FetchABlockByHeight(blockHeight uint32) (IAdminBlock, error)
	FetchDBKeyMRByHeight(dBlockHeight uint32) (dBlockKeyMR IHash, err error)
	FetchDBlock(IHash) (IDirectoryBlock, error)
	FetchDBlockByHeight(uint32) (IDirectoryBlock, error)
	FetchDBlockHead() (IDirectoryBlock, error)
	FetchEBlock(IHash) (IEntryBlock, error)
	FetchEBlockHead(chainID IHash) (IEntryBlock, error)
	FetchECBlock(IHash) (IEntryCreditBlock, error)
	FetchECBlockByHeight(blockHeight uint32) (IEntryCreditBlock, error)
	FetchECTransaction(hash IHash) (IECBlockEntry, error)
	FetchEntry(IHash) (IEBEntry, error)
	FetchFBlock(IHash) (IFBlock, error)
	FetchFBlockByHeight(blockHeight uint32) (IFBlock, error)
	FetchFactoidTransaction(hash IHash) (ITransaction, error)
	FetchHeadIndexByChainID(chainID IHash) (IHash, error)
	FetchIncludedIn(hash IHash) (IHash, error)
	FetchPaidFor(hash IHash) (IHash, error)
	FetchAllEBlocksByChain(IHash) ([]IEntryBlock, error)
	InsertEntryMultiBatch(entry IEBEntry) error
	InsertEntry(entry IEBEntry) error
	ProcessABlockMultiBatch(block DatabaseBatchable) error
	ProcessDBlockMultiBatch(block DatabaseBlockWithEntries) error
	ProcessEBlockBatch(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessEBlockMultiBatch(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessEBlockMultiBatchWithoutHead(eblock DatabaseBlockWithEntries, checkForDuplicateEntries bool) error
	ProcessECBlockMultiBatch(IEntryCreditBlock, bool) (err error)
	ProcessFBlockMultiBatch(DatabaseBlockWithEntries) error
	FetchDirBlockInfoByKeyMR(hash IHash) (IDirBlockInfo, error)
	SetExportData(path string)
	StartMultiBatch()
	Trim()
	FetchAllEntriesByChainID(chainID IHash) ([]IEBEntry, error)
	SaveKeyValueStore(kvs BinaryMarshallable, key []byte) error
	FetchKeyValueStore(key []byte, dst BinaryMarshallable) (BinaryMarshallable, error)
	SaveDatabaseEntryHeight(height uint32) error
	FetchDatabaseEntryHeight() (uint32, error)
}

A simplified DBOverlay to make sure we are not calling functions that could cause problems

type DBStateSent

type DBStateSent struct {
	DBHeight uint32
	Sent     Timestamp
}

type DatabaseBatchable

type DatabaseBatchable interface {
	BinaryMarshallableAndCopyable
	GetDatabaseHeight() uint32

	DatabasePrimaryIndex() IHash   //block.KeyMR()
	DatabaseSecondaryIndex() IHash //block.GetHash()

	GetChainID() IHash
}

type DatabaseBlockWithEntries

type DatabaseBlockWithEntries interface {
	DatabaseBatchable

	GetEntryHashes() []IHash
	GetEntrySigHashes() []IHash
}

type IABEntry

type IABEntry interface {
	Printable
	BinaryMarshallable
	ShortInterpretable

	UpdateState(IState) error // When loading Admin Blocks,

	Type() byte
	Hash() IHash
}

type IABlockHeader

type IABlockHeader interface {
	Printable
	BinaryMarshallable

	IsSameAs(IABlockHeader) bool
	GetAdminChainID() IHash
	GetDBHeight() uint32
	GetPrevBackRefHash() IHash
	SetDBHeight(uint32)
	SetPrevBackRefHash(IHash)

	GetHeaderExpansionArea() []byte
	SetHeaderExpansionArea([]byte)

	GetBodySize() uint32
	GetMessageCount() uint32
	SetBodySize(uint32)
	SetMessageCount(uint32)
}

Admin Block Header

type IAddress

type IAddress interface {
	IHash
}

type IAdminBlock

type IAdminBlock interface {
	Printable
	DatabaseBatchable

	IsSameAs(IAdminBlock) bool
	BackReferenceHash() (IHash, error)
	GetABEntries() []IABEntry
	GetDBHeight() uint32
	GetDBSignature() IABEntry
	GetHash() IHash
	GetHeader() IABlockHeader
	GetKeyMR() (IHash, error)
	LookupHash() (IHash, error)
	RemoveFederatedServer(IHash) error
	SetABEntries([]IABEntry)
	SetHeader(IABlockHeader)
	AddEntry(IABEntry) error
	FetchCoinbaseDescriptor() IABEntry

	InsertIdentityABEntries() error
	AddABEntry(e IABEntry) error
	AddAuditServer(IHash) error
	AddDBSig(serverIdentity IHash, sig IFullSignature) error
	AddFedServer(IHash) error
	AddFederatedServerBitcoinAnchorKey(IHash, byte, byte, [20]byte) error
	AddFederatedServerSigningKey(IHash, [32]byte) error
	AddFirstABEntry(e IABEntry) error
	AddMatryoshkaHash(IHash, IHash) error
	AddServerFault(IABEntry) error
	AddCoinbaseDescriptor(outputs []ITransAddress) error
	AddEfficiency(chain IHash, efficiency uint16) error
	AddCoinbaseAddress(chain IHash, add IAddress) error
	AddCancelCoinbaseDescriptor(descriptorHeight, index uint32) error

	UpdateState(IState) error
}

Administrative Block This is a special block which accompanies this Directory Block. It contains the signatures and organizational data needed to validate previous and future Directory Blocks. This block is included in the DB body. It appears there with a pair of the Admin AdminChainID:SHA256 of the block. For more details, please go to: https://github.com/DCNT-Hammer/dcntocs/blob/master/dcntataStructureDetails.md#administrative-block

type IAnchor

type IAnchor interface {
	InitRPCClient() error
	UpdateDirBlockInfoMap(dirBlockInfo IDirBlockInfo)
}

type IAnchorRecord

type IAnchorRecord interface {
	Marshal() ([]byte, error)
	MarshalAndSign(priv Signer) ([]byte, error)
	Unmarshal(data []byte) error
}

type IAuthority

type IAuthority interface {
	Type() int
	VerifySignature([]byte, *[constants.SIGNATURE_LENGTH]byte) (bool, error)
	GetAuthorityChainID() IHash
	GetSigningKey() []byte
	BinaryMarshallable
}

type IConfirmation

type IConfirmation interface {
	IMsg

	DBHeight() int      // Directory Block Height
	ChainID() []byte    // ChainID of the sending server
	ListHeight() int    // Height in the Process List
	SerialHash() []byte // Serial Hash so far

}

type IDBEntry

type IDBEntry interface {
	Printable
	BinaryMarshallable
	GetChainID() IHash
	SetChainID(IHash)
	GetKeyMR() IHash
	SetKeyMR(IHash)
	IsSameAs(IDBEntry) bool
}

type IDatabase

type IDatabase interface {
	Close() error
	Put(bucket, key []byte, data BinaryMarshallable) error
	Get(bucket, key []byte, destination BinaryMarshallable) (BinaryMarshallable, error)
	Delete(bucket, key []byte) error
	ListAllKeys(bucket []byte) ([][]byte, error)
	GetAll(bucket []byte, sample BinaryMarshallableAndCopyable) ([]BinaryMarshallableAndCopyable, [][]byte, error)
	Clear(bucket []byte) error
	PutInBatch(records []Record) error
	ListAllBuckets() ([][]byte, error)
	Trim()
	DoesKeyExist(bucket, key []byte) (bool, error)
}

type IDirBlockInfo

type IDirBlockInfo interface {
	Printable
	DatabaseBatchable
	GetDBHeight() uint32
	GetBTCConfirmed() bool
	GetDBMerkleRoot() IHash
	GetBTCTxHash() IHash
	GetTimestamp() Timestamp
	GetBTCBlockHeight() int32
}

type IDirectoryBlock

type IDirectoryBlock interface {
	Printable
	DatabaseBlockWithEntries

	GetHeader() IDirectoryBlockHeader
	SetHeader(IDirectoryBlockHeader)
	GetDBEntries() []IDBEntry
	GetEBlockDBEntries() []IDBEntry
	SetDBEntries([]IDBEntry) error
	AddEntry(chainID IHash, keyMR IHash) error
	BuildKeyMerkleRoot() (IHash, error)
	BuildBodyMR() (IHash, error)
	GetKeyMR() IHash
	GetHash() IHash
	GetFullHash() IHash
	GetHeaderHash() (IHash, error)

	GetTimestamp() Timestamp
	BodyKeyMR() IHash
	GetEntryHashesForBranch() []IHash

	SetEntryHash(hash, chainID IHash, index int)
	SetABlockHash(aBlock IAdminBlock) error
	SetECBlockHash(ecBlock IEntryCreditBlock) error
	SetFBlockHash(fBlock IFBlock) error
	IsSameAs(IDirectoryBlock) bool
}

type IDirectoryBlockHeader

type IDirectoryBlockHeader interface {
	Printable
	BinaryMarshallable

	GetVersion() byte
	SetVersion(byte)
	GetPrevFullHash() IHash
	SetPrevFullHash(IHash)
	GetBodyMR() IHash
	SetBodyMR(IHash)
	GetPrevKeyMR() IHash
	SetPrevKeyMR(IHash)
	GetHeaderHash() (IHash, error)
	GetDBHeight() uint32
	SetDBHeight(uint32)
	GetBlockCount() uint32
	SetBlockCount(uint32)
	GetNetworkID() uint32
	SetNetworkID(uint32)
	GetTimestamp() Timestamp
	SetTimestamp(Timestamp)
	IsSameAs(IDirectoryBlockHeader) bool
}

type IEBEntry

type IEBEntry interface {
	DatabaseBatchable
	Printable

	GetHash() IHash
	ExternalIDs() [][]byte
	GetContent() []byte
	GetChainIDHash() IHash
	IsSameAs(IEBEntry) bool
}

type IEBlockBody

type IEBlockBody interface {
	Printable

	AddEBEntry(IHash)
	AddEndOfMinuteMarker(m byte)
	GetEBEntries() []IHash
	MR() IHash
	IsSameAs(IEBlockBody) bool
}

type IECBlockBody

type IECBlockBody interface {
	String() string
	GetEntries() []IECBlockEntry
	SetEntries([]IECBlockEntry)
	AddEntry(IECBlockEntry)
	IsSameAs(IECBlockBody) bool
}

type IECBlockEntry

type IECBlockEntry interface {
	Printable
	ShortInterpretable

	ECID() byte
	MarshalBinary() ([]byte, error)
	UnmarshalBinary(data []byte) error
	UnmarshalBinaryData(data []byte) ([]byte, error)
	Hash() IHash
	GetHash() IHash
	GetEntryHash() IHash
	GetSigHash() IHash
	GetTimestamp() Timestamp
	IsSameAs(IECBlockEntry) bool
}

type IECBlockHeader

type IECBlockHeader interface {
	BinaryMarshallable

	String() string
	GetBodyHash() IHash
	SetBodyHash(IHash)
	GetPrevHeaderHash() IHash
	SetPrevHeaderHash(IHash)
	GetPrevFullHash() IHash
	SetPrevFullHash(IHash)
	GetDBHeight() uint32
	SetDBHeight(uint32)
	GetECChainID() IHash
	SetHeaderExpansionArea([]byte)
	GetHeaderExpansionArea() []byte
	GetObjectCount() uint64
	SetObjectCount(uint64)
	GetBodySize() uint64
	SetBodySize(uint64)
	IsSameAs(IECBlockHeader) bool
}

type IElectionAdapter

type IElectionAdapter interface {
	Execute(IMsg) IMsg
	GetDBHeight() int
	GetMinute() int
	GetElecting() int
	GetVMIndex() int

	MessageLists() string
	Status() string
	VolunteerControlsStatus() string

	// An observer does not participate in election voting
	IsObserver() bool
	SetObserver(o bool)

	// Processed indicates the election swap happened
	IsElectionProcessed() bool
	SetElectionProcessed(swapped bool)
	IsStateProcessed() bool
	SetStateProcessed(swapped bool)

	GetAudits() []IHash
}

type IElectionMsg

type IElectionMsg interface {
	IMsg
	ElectionProcess(IState, IElections)
	ElectionValidate(IElections) int
}

type IElections

type IElections interface {
	GetFedID() IHash
	GetElecting() int
	GetVMIndex() int
	GetRound() []int
	GetFederatedServers() []IServer
	GetAuditServers() []IServer
	GetAdapter() IElectionAdapter
	String() string
}

type IElectionsFactory

type IElectionsFactory interface {
	// Messages
	NewAddLeaderInternal(Name string, dbheight uint32, serverID IHash) IMsg
	NewAddAuditInternal(name string, dbheight uint32, serverID IHash) IMsg
	NewRemoveLeaderInternal(name string, dbheight uint32, serverID IHash) IMsg
	NewRemoveAuditInternal(name string, dbheight uint32, serverID IHash) IMsg
	NewEomSigInternal(name string, dbheight uint32, minute uint32, vmIndex int, height uint32, serverID IHash) IMsg
	NewDBSigSigInternal(name string, dbheight uint32, minute uint32, vmIndex int, height uint32, serverID IHash) IMsg
	NewAuthorityListInternal(feds []IServer, auds []IServer, height uint32) IMsg
}

type IEntry

type IEntry interface {
	IEBEntry
	KSize() int
}

type IEntryBlock

type IEntryBlock interface {
	Printable
	DatabaseBatchable

	GetHeader() IEntryBlockHeader

	// AddEBEntry creates a new Entry Block Entry from the provided Factom Entry
	// and adds it to the Entry Block Body.
	AddEBEntry(entry IEBEntry) error
	// AddEndOfMinuteMarker adds the End of Minute to the Entry Block. The End of
	// Minut byte becomes the last byte in a 32 byte slice that is added to the
	// Entry Block Body as an Entry Block Entry.
	AddEndOfMinuteMarker(m byte) error
	// BuildHeader updates the Entry Block Header to include information about the
	// Entry Block Body. BuildHeader should be run after the Entry Block Body has
	// included all of its EntryEntries.
	BuildHeader() error
	// Hash returns the simple Sha256 hash of the serialized Entry Block. Hash is
	// used to provide the PrevFullHash to the next Entry Block in a Chain.
	Hash() (IHash, error)
	// KeyMR returns the hash of the hash of the Entry Block Header concatenated
	// with the Merkle Root of the Entry Block Body. The Body Merkle Root is
	// calculated by the func (e *EBlockBody) MR() which is called by the func
	// (e *EBlock) BuildHeader().
	KeyMR() (IHash, error)

	GetBody() IEBlockBody

	BodyKeyMR() IHash
	GetEntryHashes() []IHash
	GetEntrySigHashes() []IHash
	GetHash() IHash
	HeaderHash() (IHash, error)
	IsSameAs(IEntryBlock) bool
}

type IEntryBlockHeader

type IEntryBlockHeader interface {
	Printable
	BinaryMarshallable

	GetBodyMR() IHash
	GetChainID() IHash
	GetPrevFullHash() IHash
	GetPrevKeyMR() IHash
	SetBodyMR(bodyMR IHash)
	SetChainID(IHash)
	SetPrevFullHash(IHash)
	SetPrevKeyMR(IHash)

	GetDBHeight() uint32
	GetEBSequence() uint32
	GetEntryCount() uint32
	SetDBHeight(uint32)
	SetEBSequence(uint32)
	SetEntryCount(uint32)
	IsSameAs(IEntryBlockHeader) bool
}

type IEntryCreditBlock

type IEntryCreditBlock interface {
	Printable
	DatabaseBatchable

	GetHeader() IECBlockHeader
	GetBody() IECBlockBody
	GetHash() IHash
	HeaderHash() (IHash, error)
	GetFullHash() (IHash, error)
	GetEntryHashes() []IHash
	GetEntrySigHashes() []IHash
	GetEntries() []IECBlockEntry
	GetEntryByHash(hash IHash) IECBlockEntry

	UpdateState(IState) error
	IsSameAs(IEntryCreditBlock) bool
	BuildHeader() error
}

type IFBlock

type IFBlock interface {
	BinaryMarshallable
	Printable
	GetHash() IHash // Returns the hash of the object

	//DatabaseBlockWithEntries
	GetDatabaseHeight() uint32
	DatabasePrimaryIndex() IHash   //block.KeyMR()
	DatabaseSecondaryIndex() IHash //block.GetHash()
	New() BinaryMarshallableAndCopyable
	GetEntryHashes() []IHash
	GetEntrySigHashes() []IHash
	GetTransactionByHash(hash IHash) ITransaction

	// Get the ChainID. This is a constant for all Factoids.
	GetChainID() IHash
	// Validation functions
	Validate() error
	ValidateTransaction(int, ITransaction) error
	// Marshal just the header for the block. This is to include the header
	// in the FullHash
	MarshalHeader() ([]byte, error)
	// Marshal just the transactions.  This is because we need the length
	MarshalTrans() ([]byte, error)
	// Add a coinbase transaction.  This transaction has no inputs
	AddCoinbase(ITransaction) error
	// Add a proper transaction.  Transactions are validated before
	// being added to the block.
	AddTransaction(ITransaction) error
	// Calculate all the MR and serial hashes for this block.  Done just
	// prior to being persisted.
	CalculateHashes()
	// Hash accessors
	// Get Key MR() hashes the header with the GetBodyMR() of the transactions
	GetKeyMR() IHash
	// Get the MR for the list of transactions
	GetBodyMR() IHash
	// Get the KeyMR of the previous block.
	GetPrevKeyMR() IHash
	SetPrevKeyMR(IHash)
	GetLedgerKeyMR() IHash
	GetPrevLedgerKeyMR() IHash
	SetPrevLedgerKeyMR(IHash)
	// Accessors for the Directory Block Height
	SetDBHeight(uint32)
	GetDBHeight() uint32
	// Accessors for the Exchange rate
	SetExchRate(uint64)
	GetExchRate() uint64
	// Accessors for the transactions
	GetTransactions() []ITransaction

	// Mark an end of Minute.  If there are multiple calls with the same minute value
	// the later one simply overwrites the previous one.  Since this is an informational
	// data point, we do not enforce much, other than order (the end of period one can't
	// come before period 2.  We just adjust the periods accordingly.
	EndOfPeriod(min int)
	GetEndOfPeriod() [10]int
	// Returns the milliTimestamp of the coinbase transaction.  This is used to validate
	// the timestamps of transactions included in the block. Transactions prior to the
	// TRANSACTION_PRIOR_LIMIT or after the TRANSACTION_POST_LIMIT are considered invalid
	// for this block. -1 is returned if no coinbase transaction is found.
	GetCoinbaseTimestamp() Timestamp

	GetNewInstance() IFBlock // Get a new instance of this object
	IsSameAs(IFBlock) bool
}

type IFEREntry

type IFEREntry interface {
	GetVersion() string
	SetVersion(passedVersion string) IFEREntry
	GetExpirationHeight() uint32
	SetExpirationHeight(passedExpirationHeight uint32) IFEREntry
	GetResidentHeight() uint32
	SetResidentHeight(passedGetResidentHeight uint32) IFEREntry
	GetTargetActivationHeight() uint32
	SetTargetActivationHeight(passedTargetActivationHeight uint32) IFEREntry
	GetPriority() uint32
	SetPriority(passedPriority uint32) IFEREntry
	GetTargetPrice() uint64
	SetTargetPrice(passedTargetPrice uint64) IFEREntry
}

type IFactoidState

type IFactoidState interface {

	// Get the current transaction block
	GetCurrentBlock() IFBlock

	// Get the current balance for a transaction
	GetFactoidBalance(address [32]byte) int64
	GetECBalance(address [32]byte) int64

	// Add a transaction   Useful for catching up with the network.
	AddTransactionBlock(IFBlock) error
	AddECBlock(IEntryCreditBlock) error

	// Get a hash of all the balances at this height
	GetBalanceHash(bool) IHash

	// Validate transaction
	// Return zero len string if the balance of an address covers each input
	Validate(int, ITransaction) (err error, holdAddr [32]byte)

	// Check the transaction timestamp for to ensure it can be included
	// in the current   Transactions that are too old, or dated to
	// far in the future cannot be included in the current block
	ValidateTransactionAge(trans ITransaction) error

	// Update Transaction just updates the balance sheet with the
	// addition of a transaction.  bool must be true if this is a realtime update,
	// and false if processing a block.  This provides real time balances, without
	// double counting transactions when we process blocks.
	UpdateTransaction(bool, ITransaction) error
	UpdateECTransaction(bool, IECBlockEntry) error

	// Add a Transaction to the current   The transaction is
	// validated against the address balances, which must cover The
	// inputs.  Returns true if the transaction is added.
	AddTransaction(int, ITransaction) error

	// Process End of Block
	ProcessEndOfBlock(IState)

	// Set the End of Period.  Currently, each block in Factom is broken
	// into ten, one minute periods.
	EndOfPeriod(period int)

	//GetMultipleFactoidBalances([][32]byte) (uint32, [][]string)
	GetMultipleFactoidBalances([32]byte) (uint32, uint32, int64, int64, string)

	GetMultipleECBalances([32]byte) (uint32, uint32, int64, int64, string)
}

type IFactomConfig

type IFactomConfig interface {
}

Holds the state information for dcnt. This does imply that we will be using accessors to access state information in the consensus algorithm. This is a bit tedious, but does provide single choke points where information can be logged about the execution of Factom. Also ensures that we do not accidentally

type IFedVoteMsg

type IFedVoteMsg interface {
	ComparisonMinute() int
}

type IFullSignature

type IFullSignature interface {
	BinaryMarshallable

	SetSignature(sig []byte) error // Set or update the signature
	GetSignature() *[64]byte
	CustomMarshalText() ([]byte, error)
	Bytes() []byte

	SetPub(publicKey []byte)
	// Get the public key
	GetKey() []byte
	// Validate data against this signature
	Verify(data []byte) bool
	IsSameAs(IFullSignature) bool
}

type IGeneralMsg

type IGeneralMsg interface {
	CreateMsg(messageType byte) IMsg
	UnmarshalMessage(data []byte) (IMsg, error)
	UnmarshalMessageData(data []byte) (newdata []byte, msg IMsg, err error)
	MessageName(Type byte) string
}

type IHash

type IHash interface {
	BinaryMarshallableAndCopyable
	Printable

	Copy() IHash
	Fixed() [32]byte       // Returns the fixed array for use in maps
	PFixed() *[32]byte     // Return a pointer to a Fixed array
	Bytes() []byte         // Return the byte slice for this Hash
	SetBytes([]byte) error // Set the bytes
	IsSameAs(IHash) bool   // Compare two Hashes
	IsMinuteMarker() bool
	UnmarshalText(b []byte) error
	IsZero() bool
	ToMinute() byte
	IsHashNil() bool
}

type IIdentityABEntry

type IIdentityABEntry interface {
	IABEntry
	// Identity to sort by
	SortedIdentity() IHash
}

type IIdentityABEntrySort

type IIdentityABEntrySort []IIdentityABEntry

func (IIdentityABEntrySort) Len

func (p IIdentityABEntrySort) Len() int

func (IIdentityABEntrySort) Less

func (p IIdentityABEntrySort) Less(i, j int) bool

func (IIdentityABEntrySort) Swap

func (p IIdentityABEntrySort) Swap(i, j int)

type IMLog

type IMLog interface {
}

type IManagerController

type IManagerController interface {
	// Manager functions extended
	RetrieveDBStateByHeight(height uint32) error
	UploadDBStateBytes(data []byte, sign bool) error
	UploadIfOnDisk(height uint32) bool
	CompletedHeightTo(height uint32) error

	// Control function
	IsBufferEmpty() bool
	FetchFromBuffer() []byte
	SetSigningKey(sec []byte) error

	// Plugin Control
	Alive() error
}

IManagerController is the interface we are exposing as a plugin. It is not directly a manager interface, as we have to handle goroutines in the plugin

type IMsg

type IMsg interface {
	Printable
	BinaryMarshallable

	// Returns a byte indicating the type of message.
	Type() byte

	// A local message is never broadcast to the greater network.
	IsLocal() bool
	SetLocal(bool)

	// A local message is never broadcast to the greater network.
	IsNetwork() bool
	SetNetwork(bool)

	// FullBroadcast means send to every node
	IsFullBroadcast() bool
	SetFullBroadcast(bool)

	// Returns the origin of this message; used to track
	// where a message came from. If int == -1, then this
	// FactomNode generated the message.
	GetOrigin() int
	SetOrigin(int)

	GetNetworkOrigin() string
	SetNetworkOrigin(string)

	// Returns the timestamp for a message
	GetTimestamp() Timestamp

	// This is the hash used to check for repeated messages.  Almost always this
	// is the MsgHash, however for Chain Commits, Entry Commits, and Factoid Transactions,
	// this is the GetHash().
	GetRepeatHash() IHash

	// Hash for this message as used by Consensus (i.e. what we match). Does not include
	// signatures to avoid Signature Maliation attacks.
	GetHash() IHash

	// Hash of this message.  Each message must be unique includes signatures
	GetMsgHash() IHash

	// Returns the full message hash of a message (includes signatures)
	GetFullMsgHash() IHash

	// If this message should only reply to a peer, this is true.  If to
	// be broadcast, this should be false.  If the Origin is 0, then the
	// network can pick a peer to try.  If Origin is > 0, then the message
	// must go back to that peer (this message is a reply).
	IsPeer2Peer() bool
	SetPeer2Peer(bool)

	// Validate the message, given the state.  Three possible results:
	//  < 0 -- Message is invalid.  Discard
	//  0   -- Cannot tell if message is Valid
	//  1   -- Message is valid
	Validate(IState) int

	//Set the VMIndex for a message
	ComputeVMIndex(IState)

	// Call here if the server is a leader
	LeaderExecute(IState)

	// Debugging thing to track the leader responsible for a message ack.
	GetLeaderChainID() IHash
	SetLeaderChainID(IHash)

	// Call here if the server is a follower
	FollowerExecute(IState)

	// Send this message out over the NetworkOutQueue.  This is done with a method
	// to allow easier debugging and simulation.
	SendOut(IState, IMsg)

	// Some messages (DBState messages, missing data messages) must be explicitly sent.
	// We won't resend them or pass them on.
	GetNoResend() bool
	SetNoResend(bool)
	GetResendCnt() int

	// Process.  When we get a sequence of acknowledgements that we trust, we process.
	// A message will only be processed once, and in order, guaranteed.
	// Returns true if able to process, false if process is waiting on something.
	Process(dbheight uint32, state IState) bool

	// Some Messages need to be processed on certain VMs.  We set this and query
	// the indexes of these machines here.
	GetVMIndex() int
	SetVMIndex(int)
	GetVMHash() []byte
	SetVMHash([]byte)
	GetMinute() byte
	SetMinute(byte)

	// Stall handling
	MarkSentInvalid(bool)
	SentInvalid() bool

	IsStalled() bool
	SetStall(bool)
	Expire(IState) bool

	// Equivalent to String() for logging
	LogFields() log.Fields
}

type IMsgAck

type IMsgAck interface {
	IMsg
	GetDBHeight() uint32
}

type IMsgFactory

type IMsgFactory interface {
	UnmarshalMessageData(data []byte) (newdata []byte, msg IMsg, err error)
	MessageName(Type byte) string
	SignSignable(s Signable, key Signer) (IFullSignature, error)
	VerifyMessage(s Signable) (bool, error)
}

type IMsgInternal

type IMsgInternal interface {
	IMsg
	ProcessElections(IState, IElectionMsg)
}

Internal Messaging supporting Elections

type INetwork

type INetwork interface {
	Receive() IMsg
	Broadcast(IMsg)
	SendToPeer(IMsg)
	Control()
	GetMLog() IMLog
	SetMLog(IMLog)
}

type IPeer

type IPeer interface {
	Init(nameTo, nameFrom string) IPeer // Name of peer
	GetNameTo() string                  // Return the name of the peer
	GetNameFrom() string                // Return the name of the peer
	Send(IMsg) error                    // Send a message to this peer
	Receive() (IMsg, error)             // Receive a message from this peer; nil if no message is ready.
	Len() int                           // Returns the number of messages waiting to be read
	Equals(IPeer) bool                  // Is this connection equal to parm connection
	Weight() int                        // How many nodes does this peer represent?
	BytesOut() int                      // Bytes sent out per second from this peer
	BytesIn() int                       // Bytes received per second from this peer
}

The Peer interface allows Factom to connect to any implementation of a p2p network. The simulator uses an implementation of IPeer to simulate various networks

type IPendingEntry

type IPendingEntry struct {
	EntryHash IHash  `json:"entryhash"`
	ChainID   IHash  `json:"chainid"`
	Status    string `json:"status"`
}

type IPendingTransaction

type IPendingTransaction struct {
	TransactionID IHash           `json:"transactionid"`
	Status        string          `json:"status"`
	Inputs        []ITransAddress `json:"inputs"`
	Outputs       []ITransAddress `json:"outputs"`
	ECOutputs     []ITransAddress `json:"ecoutputs"`
	Fees          uint64          `json:"fees"`
}

type IProcessList

type IProcessList interface {
	//Clear()
	GetKeysNewEntries() (keys [][32]byte)
	GetNewEntry(key [32]byte) IEntry
	LenNewEntries() int
	Complete() bool
	VMIndexFor(hash []byte) int
	GetVMStatsForFedServer(index int) (vmIndex int, listHeight int, listLength int, nextNil int)
	SortFedServers()
	SortAuditServers()
	SortDBSigs()
	FedServerFor(minute int, hash []byte) IServer
	GetVirtualServers(minute int, identityChainID IHash) (found bool, index int)
	GetFedServerIndexHash(identityChainID IHash) (bool, int)
	GetAuditServerIndexHash(identityChainID IHash) (bool, int)
	MakeMap()
	PrintMap() string
	AddFedServer(identityChainID IHash) int
	AddAuditServer(identityChainID IHash) int
	RemoveFedServerHash(identityChainID IHash)
	RemoveAuditServerHash(identityChainID IHash)
	String() string
	GetDBHeight() uint32
}

type IQueue

type IQueue interface {
	Length() int
	Cap() int
	Enqueue(msg IMsg)
	Dequeue() IMsg
	BlockingDequeue() IMsg
}

IQueue is the interface returned by returning queue functions

type IRCD

type IRCD interface {
	BinaryMarshallable
	Printable

	CheckSig(trans ITransaction, sigblk ISignatureBlock) bool
	Clone() IRCD
	CustomMarshalText() ([]byte, error)
	GetAddress() (IAddress, error)
	NumberOfSignatures() int
	IsSameAs(IRCD) bool
}

type IRCD_1

type IRCD_1 interface {
	IRCD
	GetPublicKey() []byte
}

type IRequest

type IRequest interface {
}

type ISCDatabaseOverlay

type ISCDatabaseOverlay interface {
	DBOverlay

	FetchWalletEntryByName(addr []byte) (IWalletEntry, error)
	FetchWalletEntryByPublicKey(addr []byte) (IWalletEntry, error)
	FetchAllWalletEntriesByName() ([]IWalletEntry, error)
	FetchAllWalletEntriesByPublicKey() ([]IWalletEntry, error)
	FetchAllAddressNameKeys() ([][]byte, error)
	FetchAllAddressPublicKeys() ([][]byte, error)
	FetchTransaction(key []byte) (ITransaction, error)
	SaveTransaction(key []byte, tx ITransaction) error
	DeleteTransaction(key []byte) error
	FetchAllTransactionKeys() ([][]byte, error)
	FetchAllTransactions() ([]ITransaction, error)
	SaveRCDAddress(key []byte, we IWalletEntry) error
	SaveAddressByPublicKey(key []byte, we IWalletEntry) error
	SaveAddressByName(key []byte, we IWalletEntry) error
}

type ISCWallet

type ISCWallet interface {
	//initialize the object.  call before using other functions
	Init(string, string)
	// A New Seed is generated for the wallet.
	NewSeed(data []byte)
	// Set the seed for a wallet
	SetSeed(seed []byte)
	// Get the seed for a wallet
	GetSeed() []byte
	// Set the current deterministic root (Initialization function)
	SetRoot([]byte)
	// Returns the backing database for the wallet
	GetDB() ISCDatabaseOverlay
	// Import a key pair.  If the private key is null, this is treated as an
	// external address, useful only as a destination
	AddKeyPair(addrtype string, name []byte, public []byte, private []byte, generateRandomIfAddressPresent bool) (IAddress, error)
	// Generate a Factoid Address
	GenerateFctAddress(name []byte, m int, n int) (IAddress, error)
	// Generate an Entry Credit Address
	GenerateECAddress(name []byte) (IAddress, error)

	// Generate a Factoid Address from a private key
	GenerateFctAddressFromPrivateKey(name []byte, privateKey []byte, m int, n int) (IAddress, error)
	// Generate an Entry Credit Address from a privatekey
	GenerateECAddressFromPrivateKey(name []byte, privateKey []byte) (IAddress, error)

	// Generate a Factoid Address from a human readable private key
	GenerateFctAddressFromHumanReadablePrivateKey(name []byte, privateKey string, m int, n int) (IAddress, error)
	// Generate an Entry Credit Address from a human readable private key
	GenerateECAddressFromHumanReadablePrivateKey(name []byte, privateKey string) (IAddress, error)

	// Generate a Factoid Address from a set of 12 words from the token sale
	GenerateFctAddressFromMnemonic(name []byte, mnemonic string, m int, n int) (IAddress, error)

	// Get details for an address
	GetAddressDetailsAddr(addr []byte) (IWalletEntry, error)
	// Returns the Address hash (what we use for inputs) given the public key
	GetAddressHash(IAddress) (IAddress, error)

	/** Transaction calls **/
	// Create a transaction.  This is just the bones, to which the
	// user must add inputs, outputs, and sign before submission.
	// Must pass in the time for the transaction! UTC nanoseconds
	CreateTransaction(time uint64) ITransaction
	// Modify an input.  Used to back fill the transaction fee.
	UpdateInput(ITransaction, int, IAddress, uint64) error
	// Add an input to a transaction
	AddInput(ITransaction, IAddress, uint64) error
	// Add an output to a transaction
	AddOutput(ITransaction, IAddress, uint64) error
	// Add an Entry Credit output to a transaction.  Note that these are
	// denominated in Factoids.  So you need the exchange rate to do this
	// properly.
	AddECOutput(ITransaction, IAddress, uint64) error
	// Validate a transaction.  Just checks that the inputs and outputs are
	// there and properly constructed.
	Validate(int, ITransaction) error
	// Checks that the signatures all validate.
	ValidateSignatures(ITransaction) error
	// Sign the inputs that have public keys to which we have the private
	// keys.  In the future, we will allow transactions with particular signatures
	// to be sent to other people to complete the signing process.  This will
	// be particularly useful with multisig.
	SignInputs(ITransaction) (bool, error) // True if all inputs are signed
	// Sign a CommitEntry or a CommitChain with the eckey
	SignCommit(we IWalletEntry, data []byte) []byte
}

The wallet interface uses bytes. This is because we want to handle fixed length values in our maps and the If we try to use strings, then the lengths vary based on encoding and that complicates the implementation without really making the interface more usable by developers.

type IServer

type IServer interface {
	BinaryMarshallable
	Printable

	GetChainID() IHash
	GetName() string
	IsOnline() bool
	SetOnline(bool)
	LeaderToReplace() IHash
	SetReplace(IHash)
	IsSameAs(b IServer) bool
}

This object will hold the public keys for servers that are not us, and maybe other information about servers.

type ISignable

type ISignable interface {
	Sign(privateKey []byte) error
	MarshalBinarySig() ([]byte, error)
	ValidateSignatures() error
}

type ISignableElectionMsg

type ISignableElectionMsg interface {
	IElectionMsg
	Signable
	GetVolunteerMessage() ISignableElectionMsg
}

type ISignature

type ISignature interface {
	BinaryMarshallable

	SetSignature(sig []byte) error // Set or update the signature
	GetSignature() *[64]byte
	CustomMarshalText() ([]byte, error)
	Bytes() []byte
	IsSameAs(ISignature) bool
}

type ISignatureBlock

type ISignatureBlock interface {
	BinaryMarshallable
	Printable

	AddSignature(sig ISignature)
	CustomMarshalText() ([]byte, error)
	GetSignature(int) ISignature
	GetSignatures() []ISignature
	IsSameAs(ISignatureBlock) bool
}

*************************************

  • ISign *
  • Interface for RCB Signatures *
  • The signature block holds the signatures that validate one of the RCBs.
  • Each signature has an index, so if the RCD is a multisig, you can know
  • how to apply the signatures to the addresses in the RCD. *************************************

type IState

type IState interface {
	GetRunState() runstate.RunState
	// Server
	GetFactomNodeName() string
	GetSalt(Timestamp) uint32 // A secret number computed from a TS that tests if a message was issued from this server or not
	Clone(number int) IState
	GetCfg() IFactomConfig
	GetConfigPath() string
	LoadConfig(filename string, networkFlag string)
	Init()
	String() string
	GetIdentityChainID() IHash
	SetIdentityChainID(IHash)
	Sign([]byte) IFullSignature
	Log(level string, message string)
	Logf(level string, format string, args ...interface{})
	GetServerPublicKeyString() string

	GetDBStatesSent() []*DBStateSent
	SetDBStatesSent([]*DBStateSent)

	GetDirectoryBlockInSeconds() int
	SetDirectoryBlockInSeconds(int)
	GetdcntVersion() string
	GetDBHeightComplete() uint32
	GetDBHeightAtBoot() uint32
	DatabaseContains(hash IHash) bool
	SetOut(bool)  // Output is turned on if set to true
	GetOut() bool // Return true if Print or Println write output
	LoadDataByHash(requestedHash IHash) (BinaryMarshallable, int, error)
	LoadDBState(dbheight uint32) (IMsg, error)
	LoadSpecificMsg(dbheight uint32, vm int, plistheight uint32) (IMsg, error)
	LoadSpecificMsgAndAck(dbheight uint32, vm int, plistheight uint32) (IMsg, IMsg, error)
	SetString()
	ShortString() string
	GetStatus() []string
	AddStatus(status string)

	AddDBSig(dbheight uint32, chainID IHash, sig IFullSignature)
	AddPrefix(string)
	AddFedServer(uint32, IHash) int
	GetFedServers(uint32) []IServer
	RemoveFedServer(uint32, IHash)
	AddAuditServer(uint32, IHash) int
	GetAuditServers(uint32) []IServer
	GetOnlineAuditServers(uint32) []IServer

	//RPC
	GetRpcUser() string
	GetRpcPass() string
	SetRpcAuthHash(authHash []byte)
	GetRpcAuthHash() []byte
	GetTlsInfo() (bool, string, string)
	GetdcntLocations() string
	GetCorsDomains() []string

	// Routine for handling the syncroniztion of the leader and follower processes
	// and how they process messages.
	Process() (progress bool)
	// This is the highest block completed.  It may or may not be saved in the Database.  This
	// is a follower's state, but it is also critical to validation; we cannot
	// validate transactions where the HighestRecordedBlock+1 != block holding said
	// transaction.
	GetHighestSavedBlk() uint32
	// This is the highest block saved in the Database. A block is completed, then validated
	// then saved.
	GetHighestCompletedBlk() uint32
	// This is the Leader's view of the Height. It must be == HighestRecordedBlock+1.  Since
	// Recording a block can take time, messages must be queued until the previous block is
	// recorded (either by processing messages, or timing out and Leaders signing off the block)
	GetLeaderHeight() uint32
	// The highest block for which we have received a message. This is a
	// Follower's understanding of the Height, and reflects what block
	// is receiving messages.
	GetHighestKnownBlock() uint32

	// Find a Directory Block by height
	GetDirectoryBlockByHeight(dbheight uint32) IDirectoryBlock

	// Network Processor
	TickerQueue() chan int
	TimerMsgQueue() chan IMsg
	NetworkOutMsgQueue() IQueue
	NetworkInvalidMsgQueue() chan IMsg

	// Journaling
	JournalMessage(IMsg)
	GetJournalMessages() [][]byte

	// Consensus
	APIQueue() IQueue    // Input Queue from the API
	InMsgQueue() IQueue  // Read by Validate
	AckQueue() chan IMsg // Ack Message Queue
	MsgQueue() chan IMsg // Other Messages Queue
	ElectionsQueue() IQueue

	// Lists and Maps
	// =====
	GetAuditHeartBeats() []IMsg // The checklist of HeartBeats for this period

	GetNewEBlocks(dbheight uint32, hash IHash) IEntryBlock
	PutNewEBlocks(dbheight uint32, hash IHash, eb IEntryBlock)
	PutNewEntries(dbheight uint32, hash IHash, eb IEntry)

	GetPendingEntries(interface{}) []IPendingEntry
	NextCommit(hash IHash) IMsg
	PutCommit(hash IHash, msg IMsg)

	IncEntryChains()
	IncEntries()
	IncECCommits()
	IncECommits()
	IncFCTSubmits()

	//Network MAIN = 0, TEST = 1, LOCAL = 2, CUSTOM = 3
	GetNetworkNumber() int  // Encoded into Directory Blocks
	GetNetworkName() string // Some networks have defined names
	GetNetworkID() uint32

	// Bootstrap Identity Information is dependent on Network
	GetNetworkBootStrapKey() IHash
	GetNetworkBootStrapIdentity() IHash

	// Skeleton Identity Information.
	GetNetworkSkeletonIdentity() IHash
	GetNetworkSkeletonKey() IHash
	IntiateNetworkSkeletonIdentity() error

	// Getting info about an identity
	GetSigningKey(id IHash) (IHash, int)

	GetMatryoshka(dbheight uint32) IHash // Reverse Hash

	// These are methods run by the consensus algorithm to track what servers are the leaders
	// and what lists they are responsible for.
	ComputeVMIndex(hash []byte) int // Returns the VMIndex determined by some hash (usually) for the current processlist
	IsLeader() bool                 // Returns true if this is the leader in the current minute
	GetLeaderVM() int               // Get the Leader VM (only good within a minute)
	// Returns the list of VirtualServers at a given directory block height and minute
	GetVirtualServers(dbheight uint32, minute int, identityChainID IHash) (found bool, index int)

	// Get the message for the given vm index, dbheight, and height.  Returns nil if I
	// have no such message.
	GetMsg(vmIndex int, dbheight int, height int) (IMsg, error)

	GetEBlockKeyMRFromEntryHash(entryHash IHash) IHash
	GetAnchor() IAnchor

	// Database
	GetDB() DBOverlaySimple

	// Web Services
	// ============
	SetPort(int)
	GetPort() int

	// Factoid State
	// =============
	UpdateState() bool
	GetSystemHeight(dbheight uint32) int
	GetFactoidState() IFactoidState

	SetFactoidState(dbheight uint32, fs IFactoidState)
	GetFactoshisPerEC() uint64
	SetFactoshisPerEC(factoshisPerEC uint64)
	IncFactoidTrans()
	IncDBStateAnswerCnt()

	GetPendingTransactions(interface{}) []IPendingTransaction

	Reset()                                    // Trim back the state to the last saved block
	GetSystemMsg(dbheight, height uint32) IMsg // Return the system message at the given height.
	SendDBSig(dbheight uint32, vmIndex int)    // If a Leader, we have to send a DBSig out for the previous block

	FollowerExecuteMsg(IMsg)          // Messages that go into the process list
	FollowerExecuteEOM(IMsg)          // Messages that go into the process list
	FollowerExecuteAck(IMsg)          // Ack Msg calls this function.
	FollowerExecuteDBState(IMsg)      // Add the given DBState to this server
	FollowerExecuteSFault(IMsg)       // Handling of Server Fault Messages
	FollowerExecuteFullFault(IMsg)    // Handle Server Full-Fault Messages
	FollowerExecuteMMR(IMsg)          // Handle Missing Message Responses
	FollowerExecuteDataResponse(IMsg) // Handle Data Response
	FollowerExecuteMissingMsg(IMsg)   // Handle requests for missing messages
	FollowerExecuteCommitChain(IMsg)  // CommitChain needs to look for a Reveal Entry
	FollowerExecuteCommitEntry(IMsg)  // CommitEntry needs to look for a Reveal Entry
	FollowerExecuteRevealEntry(IMsg)

	ProcessAddServer(dbheight uint32, addServerMsg IMsg) bool
	ProcessRemoveServer(dbheight uint32, removeServerMsg IMsg) bool
	ProcessChangeServerKey(dbheight uint32, changeServerKeyMsg IMsg) bool
	ProcessCommitChain(dbheight uint32, commitChain IMsg) bool
	ProcessCommitEntry(dbheight uint32, commitChain IMsg) bool
	ProcessDBSig(dbheight uint32, commitChain IMsg) bool
	ProcessEOM(dbheight uint32, eom IMsg) bool
	ProcessRevealEntry(dbheight uint32, m IMsg) bool
	// For messages that go into the Process List
	LeaderExecute(IMsg)
	LeaderExecuteEOM(IMsg)
	LeaderExecuteDBSig(IMsg)
	LeaderExecuteRevealEntry(IMsg)
	LeaderExecuteCommitChain(IMsg)
	LeaderExecuteCommitEntry(IMsg)

	GetNetStateOff() bool //	If true, all network communications are disabled
	SetNetStateOff(bool)

	GetTimestamp() Timestamp
	GetTimeOffset() Timestamp

	GetTrueLeaderHeight() uint32
	Print(a ...interface{}) (n int, err error)
	Println(a ...interface{}) (n int, err error)

	ValidatorLoop()

	UpdateECs(IEntryCreditBlock)
	SetIsReplaying()
	SetIsDoneReplaying()

	CrossReplayAddSalt(height uint32, salt [8]byte) error

	// No Entry Yet returns true if no Entry Hash is found in the Replay structs.
	// Returns false if we have seen an Entry Replay in the current period.
	NoEntryYet(IHash, Timestamp) bool

	// Calculates the transaction rate this node is seeing.
	//		totalTPS	: Total transactions / total time node running
	//		instantTPS	: Weighted transactions per second to get a better value for
	//					  current transaction rate.
	CalculateTransactionRate() (totalTPS float64, instantTPS float64)

	//For ACK
	GetACKStatus(hash IHash) (int, IHash, Timestamp, Timestamp, error)
	GetSpecificACKStatus(hash IHash) (int, IHash, Timestamp, Timestamp, error)

	// Acks with ChainIDs so you can select which hash type
	GetEntryCommitAckByEntryHash(hash IHash) (status int, commit IMsg)
	GetEntryRevealAckByEntryHash(hash IHash) (status int, blktime Timestamp, commit IMsg)
	GetEntryCommitAckByTXID(hash IHash) (status int, blktime Timestamp, commit IMsg, entryhash IHash)
	IsNewOrPendingEBlocks(dbheight uint32, hash IHash) bool

	// Used in API to reject commits properly and inform user
	IsHighestCommit(hash IHash, msg IMsg) bool

	FetchPaidFor(hash IHash) (IHash, error)
	FetchFactoidTransactionByHash(hash IHash) (ITransaction, error)
	FetchECTransactionByHash(hash IHash) (IECBlockEntry, error)
	FetchEntryByHash(IHash) (IEBEntry, error)
	FetchEntryHashFromProcessListsByTxID(string) (IHash, error)

	// FER section
	ProcessRecentFERChainEntries()
	ExchangeRateAuthorityIsValid(IEBEntry) bool
	FerEntryIsValid(passedFEREntry IFEREntry) bool
	GetPredictiveFER() uint64

	// Identity Section
	VerifyIsAuthority(cid IHash) bool // True if is authority
	UpdateAuthorityFromABEntry(entry IABEntry) error
	VerifyAuthoritySignature(Message []byte, signature *[64]byte, dbheight uint32) (int, error)
	FastVerifyAuthoritySignature(Message []byte, signature IFullSignature, dbheight uint32) (int, error)
	UpdateAuthSigningKeys(height uint32)
	AddIdentityFromChainID(cid IHash) error

	AddAuthorityDelta(changeString string)

	GetElections() IElections
	GetAuthorities() []IAuthority
	GetAuthorityInterface(chainid IHash) IAuthority
	GetLeaderPL() IProcessList
	GetLLeaderHeight() uint32
	GetEntryDBHeightComplete() uint32
	GetMissingEntryCount() uint32
	GetEntryBlockDBHeightProcessing() uint32
	GetEntryBlockDBHeightComplete() uint32
	GetCurrentBlockStartTime() int64
	GetCurrentMinute() int
	GetCurrentMinuteStartTime() int64
	GetPreviousMinuteStartTime() int64
	GetCurrentTime() int64
	IsStalled() bool
	GetDelay() int64
	SetDelay(int64)
	GetDropRate() int
	SetDropRate(int)
	GetBootTime() int64
	IsSyncing() bool
	IsSyncingEOMs() bool
	IsSyncingDBSigs() bool
	DidCreateLastBlockFromDBState() bool
	GetUnsyncedServers(dbheight uint32) []IHash
	Validate(msg IMsg) (validToSend int, validToExecute int)
	GetIgnoreDone() bool

	// Access to Holding Queue
	LoadHoldingMap() map[[32]byte]IMsg
	LoadAcksMap() map[[32]byte]IMsg

	// Plugins
	UsingTorrent() bool
	GetMissingDBState(height uint32) error

	LogMessage(logName string, comment string, msg IMsg)
	LogPrintf(logName string, format string, more ...interface{})

	GetHighestAck() uint32
	SetHighestAck(uint32)
	DebugExec() bool
	CheckFileName(string) bool
	AddToReplayFilter(mask int, hash [32]byte, timestamp Timestamp, systemtime Timestamp) bool

	// Activations -------------------------------------------------------
	IsActive(id activations.ActivationType) bool

	// Holding of dependent messages -------------------------------------
	// Add a messsage to a dependent holding list
	Add(h [32]byte, msg IMsg) int
	// get and remove the list of dependent message for a hash
	Get(h [32]byte) []IMsg
	// expire any dependent messages that are in holding but are older than limit
	ExecuteFromHolding(h [32]byte)
	// create a hash to hold messages that depend on height
	HoldForHeight(ht uint32, msg IMsg) int

	// test/debug filters
	PassOutputRegEx(*regexp.Regexp, string)
	GetOutputRegEx() (*regexp.Regexp, string)
	PassInputRegEx(*regexp.Regexp, string)
	GetInputRegEx() (*regexp.Regexp, string)
}

Holds the state information for dcnt. This does imply that we will be using accessors to access state information in the consensus algorithm. This is a bit tedious, but does provide single choke points where information can be logged about the execution of Factom. Also ensures that we do not accidentally

type ISystem

type ISystem interface {
	Printable
	BinaryMarshallable

	// Returns the timestamp for a message
	GetTimestamp() Timestamp

	// Send this message out over the NetworkOutQueue.  This is done with a method
	// to allow easier debugging and simulation.
	SendOut(IState, IMsg)

	Process(dbheight uint32, state IState) bool
}

type ITransAddress

type ITransAddress interface {
	BinaryMarshallable

	GetAmount() uint64
	SetAmount(uint64)
	GetAddress() IAddress
	SetAddress(IAddress)
	IsSameAs(ITransAddress) bool

	CustomMarshalTextInput() ([]byte, error)
	CustomMarshalTextOutput() ([]byte, error)
	CustomMarshalTextECOutput() ([]byte, error)

	StringInput() string
	StringOutput() string
	StringECOutput() string

	GetUserAddress() string
	SetUserAddress(string)
}

type ITransaction

type ITransaction interface {
	BinaryMarshallable
	Printable
	CustomMarshalText() ([]byte, error)

	// Marshals the parts of the transaction that are signed to
	// validate the transaction.  This includes the transaction header,
	// the locktime, the inputs, outputs, and outputs to EntryCredits.  It
	// does not include the signatures and RCDs.  The inputs are the hashes
	// of the RCDs, so they are included indirectly.  The signatures
	// sign this hash, so they are included indirectly.
	MarshalBinarySig() ([]byte, error)
	// Add an input to the transaction.  No validation.
	AddInput(input IAddress, amount uint64)
	// Add an output to the transaction.  No validation.
	AddOutput(output IAddress, amount uint64)
	// Add an Entry Credit output to the transaction.  Denominated in
	// Factoids, and interpreted by the exchange rate in the server at
	// the time the transaction is added to Factom.
	AddECOutput(ecoutput IAddress, amount uint64)
	// Add an RCD.  Must match the input in the same order.  Inputs and
	// RCDs are generally added at the same time.
	AddRCD(rcd IRCD)

	// Get the hash of the signed portion (not including signatures)
	// This is the TxID of a factoid transaction
	GetSigHash() IHash

	GetHash() IHash
	// Get the full hash of the transaction (including signatures)
	GetFullHash() IHash

	// Accessors the inputs, outputs, and Entry Credit outputs (ecoutputs)
	// to this transaction.
	GetInput(int) (ITransAddress, error)
	GetOutput(int) (ITransAddress, error)
	GetECOutput(int) (ITransAddress, error)
	GetRCD(int) (IRCD, error)
	GetInputs() []ITransAddress
	GetOutputs() []ITransAddress
	GetECOutputs() []ITransAddress
	GetRCDs() []IRCD

	GetVersion() uint64
	// Locktime serves as a nonce to make every transaction unique. Transactions
	// that are more than 24 hours old are not included nor propagated through
	// the network.
	GetTimestamp() Timestamp
	SetTimestamp(Timestamp)
	// Get a signature
	GetSignatureBlock(i int) ISignatureBlock
	SetSignatureBlock(i int, signatureblk ISignatureBlock)
	GetSignatureBlocks() []ISignatureBlock

	// Helper functions for validation.
	TotalInputs() (uint64, error)
	TotalOutputs() (uint64, error)
	TotalECs() (uint64, error)

	// Validate does everything but check the signatures.
	Validate(int) error
	ValidateSignatures() error

	// Calculate the fee for a transaction, given the specified exchange rate.
	CalculateFee(factoshisPerEC uint64) (uint64, error)

	// Wallet Support (Not sure why we need some of these)
	GetBlockHeight() uint32
	SetBlockHeight(uint32)

	// Helper Function.  This simply adds an Authorization to a
	// transaction.  DOES NO VALIDATION.  Not the job of construction.
	// That's why we have a validation call.
	AddAuthorization(auth IRCD)

	// is this user address associated with the inputs and outputs of this transaction
	HasUserAddress(userAddr string) bool

	IsSameAs(ITransaction) bool
}

type IWalletEntry

type IWalletEntry interface {
	BinaryMarshallable
	Printable

	// Set the RCD for this entry.  USE WITH CAUTION!  You change
	// the hash and thus the address returned by the wallet entry!
	SetRCD(IRCD)
	// Get the RCD used to validate an input
	GetRCD() IRCD
	// Add a public and private key.  USE WITH CAUTION! You change
	// the hash and thus the address returned by the wallet entry!
	AddKey(public, private []byte)
	// Get the name for this address
	GetName() []byte
	// Get the Public Key by its index
	GetKey(i int) []byte
	// Get the Private Key by its index
	GetPrivKey(i int) []byte
	// Set the name for this address
	SetName([]byte)
	// Get the address defined by the RCD for this wallet entry.
	GetAddress() (IAddress, error)
	// Return "ec" for Entry Credit address, and "fct" for a Factoid address
	GetType() string
	SetType(string)
}

type IndividualObj

type IndividualObj struct {
	ERROR string `json:"err"`
}

type JSONable

type JSONable interface {
	JSONByte() ([]byte, error)
	JSONString() (string, error)
}

Interface for printing structures into JSON

type Printable

type Printable interface {
	JSONable
	String() string
}

Interface for both JSON and Spew

type Record

type Record struct {
	Bucket []byte
	Key    []byte
	Data   BinaryMarshallable
}

type ShortInterpretable

type ShortInterpretable interface {
	IsInterpretable() bool //Whether the structure can interpret itself
	Interpret() string     //Turns the data encoded in the structure into human-friendly string
}

Interface for short, reoccuring data structures to interpret themselves into human-friendly form

type Signable

type Signable interface {
	Sign(Signer) error
	MarshalForSignature() ([]byte, error)
	GetSignature() IFullSignature
	IsValid() bool // Signature already checked
	SetValid()     // Mark as validated so we don't have to repeat.
}

type Signer

type Signer interface {
	Sign(msg []byte) IFullSignature
}

Signer object can Sign msg

type StructToReturnValues

type StructToReturnValues struct {
	TempBal int64  `json:"ack"`
	PermBal int64  `json:"saved"`
	Error   string `json:"err"`
}

type Timestamp

type Timestamp interface {
	SetTimestamp(b Timestamp)
	SetTimeNow()
	SetTime(miliseconds uint64)
	SetTimeSeconds(seconds int64)
	GetTime() time.Time
	UnmarshalBinaryData(data []byte) (newData []byte, err error)
	UnmarshalBinary(data []byte) error
	GetTimeSeconds() int64
	GetTimeMinutesUInt32() uint32
	GetTimeMilli() int64
	GetTimeMilliUInt64() uint64
	GetTimeSecondsUInt32() uint32
	MarshalBinary() ([]byte, error)
	String() string
	UTCString() string
	IsSameAs(Timestamp) bool
}

A structure for handling timestamps for messages

type Verifier

type Verifier interface {
	Verify(msg []byte, sig *[64]byte) bool
	String() string
}

Verifier objects can Verify signed messages

Jump to

Keyboard shortcuts

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