Documentation ¶
Index ¶
- Constants
- Variables
- func ConfirmMilestone(dbStorage *storage.Storage, serverMetrics *metrics.ServerMetrics, ...) (*ConfirmedMilestoneStats, *ConfirmationMetrics, error)
- type Confirmation
- type ConfirmationMetrics
- type ConfirmedMilestoneStats
- type Hasher
- type MessageWithConflict
- type WhiteFlagMutations
Constants ¶
const ( LeafHashPrefix = 0 NodeHashPrefix = 1 )
Domain separation prefixes
Variables ¶
var ( // ErrIncludedMessagesSumDoesntMatch is returned when the sum of the included messages a milestone approves does not match the referenced messages minus the excluded messages. ErrIncludedMessagesSumDoesntMatch = errors.New("the sum of the included messages doesn't match the referenced messages minus the excluded messages") )
Functions ¶
func ConfirmMilestone ¶
func ConfirmMilestone( dbStorage *storage.Storage, serverMetrics *metrics.ServerMetrics, messagesMemcache *storage.MessagesMemcache, metadataMemcache *storage.MetadataMemcache, milestoneMessageID hornet.MessageID, forEachReferencedMessage func(messageMetadata *storage.CachedMetadata, index milestone.Index, confTime uint64), onMilestoneConfirmed func(confirmation *Confirmation), forEachNewOutput func(index milestone.Index, output *utxo.Output), forEachNewSpent func(index milestone.Index, spent *utxo.Spent), onReceipt func(r *utxo.ReceiptTuple) error) (*ConfirmedMilestoneStats, *ConfirmationMetrics, error)
ConfirmMilestone traverses a milestone and collects all unreferenced msg, then the ledger diffs are calculated, the ledger state is checked and all msg are marked as referenced. Additionally, this function also examines the milestone for a receipt and generates new migrated outputs if one is present. The treasury is mutated accordingly. metadataMemcache has to be cleaned up outside.
Types ¶
type Confirmation ¶
type Confirmation struct { // The index of the milestone that got confirmed. MilestoneIndex milestone.Index // The message ID of the milestone that got confirmed. MilestoneMessageID hornet.MessageID // The ledger mutations and referenced messages of this milestone. Mutations *WhiteFlagMutations }
Confirmation represents a confirmation done via a milestone under the "white-flag" approach.
type ConfirmationMetrics ¶ added in v1.0.0
type ConfirmationMetrics struct { DurationWhiteflag time.Duration DurationReceipts time.Duration DurationConfirmation time.Duration DurationApplyIncludedWithTransactions time.Duration DurationApplyExcludedWithoutTransactions time.Duration DurationApplyMilestone time.Duration DurationApplyExcludedWithConflictingTransactions time.Duration DurationForEachNewOutput time.Duration DurationForEachNewSpent time.Duration DurationOnMilestoneConfirmed time.Duration DurationSetConfirmedMilestoneIndex time.Duration DurationUpdateConeRootIndexes time.Duration DurationConfirmedMilestoneChanged time.Duration DurationConfirmedMilestoneIndexChanged time.Duration DurationMilestoneConfirmedSyncEvent time.Duration DurationMilestoneConfirmed time.Duration DurationTotal time.Duration }
ConfirmationMetrics holds metrics about a confirmation run.
type ConfirmedMilestoneStats ¶
type Hasher ¶
type Hasher struct {
// contains filtered or unexported fields
}
Hasher implements the hashing algorithm described in the IOTA protocol RFC-12.
func (*Hasher) EmptyRoot ¶
EmptyRoot returns a special case for an empty tree. This is equivalent to Hash(nil).
type MessageWithConflict ¶ added in v1.0.0
type WhiteFlagMutations ¶
type WhiteFlagMutations struct { // The messages which mutate the ledger in the order in which they were applied. MessagesIncludedWithTransactions hornet.MessageIDs // The messages which were excluded as they were conflicting with the mutations. MessagesExcludedWithConflictingTransactions []MessageWithConflict // The messages which were excluded because they did not include a value transaction. MessagesExcludedWithoutTransactions hornet.MessageIDs // The messages which were referenced by the milestone (should be the sum of MessagesIncludedWithTransactions + MessagesExcludedWithConflictingTransactions + MessagesExcludedWithoutTransactions). MessagesReferenced hornet.MessageIDs // Contains the newly created Unspent Outputs by the given confirmation. NewOutputs map[string]*utxo.Output // Contains the Spent Outputs for the given confirmation. NewSpents map[string]*utxo.Spent // The merkle tree root hash of all messages. MerkleTreeHash [iotago.MilestoneInclusionMerkleProofLength]byte // contains filtered or unexported fields }
WhiteFlagMutations contains the ledger mutations and referenced messages applied to a cone under the "white-flag" approach.
func ComputeWhiteFlagMutations ¶
func ComputeWhiteFlagMutations(ctx context.Context, dbStorage *storage.Storage, msIndex milestone.Index, metadataMemcache *storage.MetadataMemcache, messagesMemcache *storage.MessagesMemcache, parents hornet.MessageIDs) (*WhiteFlagMutations, error)
ComputeWhiteFlagMutations computes the ledger changes in accordance to the white-flag rules for the cone referenced by the parents. Via a post-order depth-first search the approved messages of the given cone are traversed and in their corresponding order applied/mutated against the previous ledger state, respectively previous applied mutations. Messages within the approving cone must be valid. Messages causing conflicts are ignored but do not create an error. It also computes the merkle tree root hash consisting out of the IDs of the messages 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. metadataMemcache has to be cleaned up outside.