Documentation ¶
Index ¶
Constants ¶
const ( LeafHashPrefix = 0 NodeHashPrefix = 1 )
Domain separation prefixes
Variables ¶
var ( // ErrMilestoneApprovedInvalidBundle is returned when a milestone approves an invalid bundle in its past cone. ErrMilestoneApprovedInvalidBundle = errors.New("the milestone approved an invalid bundle") // ErrIncludedTailsSumDoesntMatch is returned when the sum of the included tails a milestone approves does not match the referenced tails minus the excluded tails. ErrIncludedTailsSumDoesntMatch = errors.New("the sum of the included tails doesn't match the referenced tails minus the excluded tails") )
Functions ¶
func ComputeWhiteFlagMutations ¶
func ComputeWhiteFlagMutations(cachedTxMetas map[string]*tangle.CachedMetadata, cachedBundles map[string]*tangle.CachedBundle, merkleTreeHashFunc crypto.Hash, trunkHash hornet.Hash, branchHash ...hornet.Hash) (*tangle.WhiteFlagMutations, error)
ComputeConfirmation computes the ledger changes in accordance to the white-flag rules for the cone referenced by trunk and branch. Via a post-order depth-first search the approved bundles of the given cone are traversed and in their corresponding order applied/mutated against the previous ledger state, respectively previous applied mutations. Bundles within the approving cone must obey to strict schematics and be valid. Bundles causing conflicts are ignored but do not create an error. It also computes the merkle tree root hash consisting out of the tail transaction hashes of the bundles which are part of the set which mutated the ledger state when applying the white-flag approach. The ledger state must be write locked while this function is getting called in order to ensure consistency. all cachedTxMetas and cachedBundles have to be released outside.
Types ¶
type ConfirmedMilestoneStats ¶
type ConfirmedMilestoneStats struct { Index milestone.Index ConfirmationTime int64 Txs tangle.CachedTransactions TxsConfirmed int TxsConflicting int TxsValue int TxsZeroValue int Collecting time.Duration Total time.Duration }
func ConfirmMilestone ¶
func ConfirmMilestone(cachedTxMetas map[string]*tangle.CachedMetadata, cachedMsBundle *tangle.CachedBundle, forEachConfirmedTx func(txMeta *tangle.CachedMetadata, index milestone.Index, confTime int64), onMilestoneConfirmed func(confirmation *tangle.WhiteFlagConfirmation)) (*ConfirmedMilestoneStats, error)
ConfirmMilestone traverses a milestone and collects all unconfirmed tx, then the ledger diffs are calculated, the ledger state is checked and all tx are marked as confirmed. all cachedTxMetas have to be released outside.
type Hasher ¶
Hasher implements the RFC6962 tree hashing algorithm.