Documentation
¶
Index ¶
- Variables
- func EC(ecRecord *epoch.ECRecord) (ec epoch.EC)
- type BootstrappedEvent
- type CommitmentProof
- type CommitmentRoots
- type CommitmentTrees
- type EpochCommitmentFactory
- func (f *EpochCommitmentFactory) ECR(ei epoch.Index) (ecr epoch.ECR, err error)
- func (f *EpochCommitmentFactory) ManaRoot() []byte
- func (f *EpochCommitmentFactory) ProofStateMutationRoot(ei epoch.Index, txID utxo.TransactionID) (*CommitmentProof, error)
- func (f *EpochCommitmentFactory) ProofStateRoot(ei epoch.Index, outID utxo.OutputID) (*CommitmentProof, error)
- func (f *EpochCommitmentFactory) ProofTangleRoot(ei epoch.Index, blockID tangle.BlockID) (*CommitmentProof, error)
- func (f *EpochCommitmentFactory) StateRoot() []byte
- func (f *EpochCommitmentFactory) VerifyStateMutationRoot(proof CommitmentProof, transactionID utxo.TransactionID) bool
- func (f *EpochCommitmentFactory) VerifyTangleRoot(proof CommitmentProof, blockID tangle.BlockID) bool
- type EpochCommitmentStorage
- type EpochCommittableEvent
- type EventMock
- type Events
- type ManaVectorUpdateEvent
- type Manager
- func (m *Manager) Bootstrapped() bool
- func (m *Manager) GetBlockInclusionProof(blockID tangle.BlockID) (*CommitmentProof, error)
- func (m *Manager) GetLatestEC() (ecRecord *epoch.ECRecord, err error)
- func (m *Manager) GetTransactionInclusionProof(transactionID utxo.TransactionID) (*CommitmentProof, error)
- func (m *Manager) LatestConfirmedEpochIndex() (epoch.Index, error)
- func (m *Manager) LoadSnapshot(snapshot *ledger.Snapshot)
- func (m *Manager) OnAcceptanceTimeUpdated(newTime time.Time)
- func (m *Manager) OnBlockAccepted(block *tangle.Block)
- func (m *Manager) OnBlockOrphaned(block *tangle.Block)
- func (m *Manager) OnConflictConfirmed(conflictID utxo.TransactionID)
- func (m *Manager) OnConflictCreated(conflictID utxo.TransactionID)
- func (m *Manager) OnConflictRejected(conflictID utxo.TransactionID)
- func (m *Manager) OnTransactionAccepted(event *ledger.TransactionAcceptedEvent)
- func (m *Manager) OnTransactionInclusionUpdated(event *ledger.TransactionInclusionUpdatedEvent)
- func (m *Manager) PendingConflictsCount(ei epoch.Index) (pendingConflictsCount uint64)
- func (m *Manager) PendingConflictsCountAll() (pendingConflicts map[epoch.Index]uint64)
- func (m *Manager) Shutdown()
- type ManagerOption
- type ManagerOptions
- type Option
- type StateMutationTreeUpdatedEvent
- type TangleTreeUpdatedEvent
- type UTXOUpdatedEvent
Constants ¶
This section is empty.
Variables ¶
var ( // TestConflictAcceptanceStateTranslation translates a conflict's AW into a confirmation state. TestConflictAcceptanceStateTranslation acceptance.ConflictThresholdTranslation = func(conflictID utxo.TransactionID, aw float64) confirmation.State { if aw >= testingAcceptanceThreshold { return confirmation.Accepted } return confirmation.Pending } // TestBlockAcceptanceStateTranslation translates a block's AW into a confirmation state. TestBlockAcceptanceStateTranslation acceptance.BlockThresholdTranslation = func(aw float64) confirmation.State { if aw >= testingAcceptanceThreshold { return confirmation.Accepted } return confirmation.Pending } )
Functions ¶
Types ¶
type BootstrappedEvent ¶
BootstrappedEvent is an event that gets triggered when a notarization manager has the last committable epoch relatively close to current epoch.
type CommitmentProof ¶
CommitmentProof represents an inclusion proof for a specific epoch.
type CommitmentRoots ¶
CommitmentRoots contains roots of trees of an epoch.
type CommitmentTrees ¶
CommitmentTrees is a compressed form of all the information (blocks and confirmed value payloads) of an epoch.
type EpochCommitmentFactory ¶
type EpochCommitmentFactory struct {
// contains filtered or unexported fields
}
EpochCommitmentFactory manages epoch commitmentTrees.
func NewEpochCommitmentFactory ¶
func NewEpochCommitmentFactory(store kvstore.KVStore, tangle *tangle.Tangle, snapshotDepth int) *EpochCommitmentFactory
NewEpochCommitmentFactory returns a new commitment factory.
func (*EpochCommitmentFactory) ManaRoot ¶
func (f *EpochCommitmentFactory) ManaRoot() []byte
ManaRoot returns the root of the state sparse merkle tree at the latest committed epoch.
func (*EpochCommitmentFactory) ProofStateMutationRoot ¶
func (f *EpochCommitmentFactory) ProofStateMutationRoot(ei epoch.Index, txID utxo.TransactionID) (*CommitmentProof, error)
ProofStateMutationRoot returns the merkle proof for the transactionID against the state mutation root.
func (*EpochCommitmentFactory) ProofStateRoot ¶
func (f *EpochCommitmentFactory) ProofStateRoot(ei epoch.Index, outID utxo.OutputID) (*CommitmentProof, error)
ProofStateRoot returns the merkle proof for the outputID against the state root.
func (*EpochCommitmentFactory) ProofTangleRoot ¶
func (f *EpochCommitmentFactory) ProofTangleRoot(ei epoch.Index, blockID tangle.BlockID) (*CommitmentProof, error)
ProofTangleRoot returns the merkle proof for the blockID against the tangle root.
func (*EpochCommitmentFactory) StateRoot ¶
func (f *EpochCommitmentFactory) StateRoot() []byte
StateRoot returns the root of the state sparse merkle tree at the latest committed epoch.
func (*EpochCommitmentFactory) VerifyStateMutationRoot ¶
func (f *EpochCommitmentFactory) VerifyStateMutationRoot(proof CommitmentProof, transactionID utxo.TransactionID) bool
VerifyStateMutationRoot verify the provided merkle proof against the state mutation root.
func (*EpochCommitmentFactory) VerifyTangleRoot ¶
func (f *EpochCommitmentFactory) VerifyTangleRoot(proof CommitmentProof, blockID tangle.BlockID) bool
VerifyTangleRoot verify the provided merkle proof against the tangle root.
type EpochCommitmentStorage ¶
type EpochCommitmentStorage struct {
// contains filtered or unexported fields
}
EpochCommitmentStorage is a Ledger component that bundles the storage related API.
func (*EpochCommitmentStorage) CachedECRecord ¶
func (s *EpochCommitmentStorage) CachedECRecord(ei epoch.Index, computeIfAbsentCallback ...func(ei epoch.Index) *epoch.ECRecord) (cachedEpochDiff *objectstorage.CachedObject[*epoch.ECRecord])
CachedECRecord retrieves cached ECRecord of the given EI. (Make sure to Release or Consume the return object.)
type EpochCommittableEvent ¶
type EpochCommittableEvent struct {
// EI is the index of committable epoch.
EI epoch.Index
// ECRecord is the ec root of committable epoch.
ECRecord *epoch.ECRecord
}
EpochCommittableEvent is a container that acts as a dictionary for the EpochCommittable event related parameters.
type EventMock ¶
EventMock acts as a container for event mocks.
func NewEventMock ¶
NewEventMock creates a new EventMock.
func (*EventMock) AssertExpectations ¶
AssertExpectations asserts expectations.
func (*EventMock) DetachAll ¶
func (e *EventMock) DetachAll()
DetachAll detaches all event handlers.
func (*EventMock) EpochCommittable ¶
func (e *EventMock) EpochCommittable(event *EpochCommittableEvent)
EpochCommittable is the mocked EpochCommittable event.
func (*EventMock) ManaVectorUpdate ¶
func (e *EventMock) ManaVectorUpdate(event *ManaVectorUpdateEvent)
ManaVectorUpdate is the mocked ManaVectorUpdate event.
type Events ¶
type Events struct {
// EpochCommittable is an event that gets triggered whenever an epoch commitment is committable.
EpochCommittable *event.Event[*EpochCommittableEvent]
ManaVectorUpdate *event.Event[*ManaVectorUpdateEvent]
// TangleTreeInserted is an event that gets triggered when a Block is inserted into the Tangle smt.
TangleTreeInserted *event.Event[*TangleTreeUpdatedEvent]
// TangleTreeRemoved is an event that gets triggered when a Block is removed from Tangle smt.
TangleTreeRemoved *event.Event[*TangleTreeUpdatedEvent]
// StateMutationTreeInserted is an event that gets triggered when a transaction is inserted into the state mutation smt.
StateMutationTreeInserted *event.Event[*StateMutationTreeUpdatedEvent]
// StateMutationTreeRemoved is an event that gets triggered when a transaction is removed from state mutation smt.
StateMutationTreeRemoved *event.Event[*StateMutationTreeUpdatedEvent]
// UTXOTreeInserted is an event that gets triggered when UTXOs are stored into the UTXO smt.
UTXOTreeInserted *event.Event[*UTXOUpdatedEvent]
// UTXOTreeRemoved is an event that gets triggered when UTXOs are removed from the UTXO smt.
UTXOTreeRemoved *event.Event[*UTXOUpdatedEvent]
// Bootstrapped is an event that gets triggered when a notarization manager has the last committable epoch relatively close to current epoch.
Bootstrapped *event.Event[*BootstrappedEvent]
}
Events is a container that acts as a dictionary for the existing events of a notarization manager.
type ManaVectorUpdateEvent ¶
type ManaVectorUpdateEvent struct {
// EI is the index of committable epoch.
EI epoch.Index
EpochDiffCreated []*ledger.OutputWithMetadata
EpochDiffSpent []*ledger.OutputWithMetadata
}
ManaVectorUpdateEvent is a container that acts as a dictionary for the EpochCommittable event related parameters.
type Manager ¶
type Manager struct {
Events *Events
// contains filtered or unexported fields
}
Manager is the notarization manager.
func NewManager ¶
func NewManager(epochCommitmentFactory *EpochCommitmentFactory, t *tangle.Tangle, opts ...ManagerOption) (new *Manager)
NewManager creates and returns a new notarization manager.
func (*Manager) Bootstrapped ¶
Bootstrapped returns the current value of pendingConflictsCount per epoch.
func (*Manager) GetBlockInclusionProof ¶
func (m *Manager) GetBlockInclusionProof(blockID tangle.BlockID) (*CommitmentProof, error)
GetBlockInclusionProof gets the proof of the inclusion (acceptance) of a block.
func (*Manager) GetLatestEC ¶
GetLatestEC returns the latest commitment that a new block should commit to.
func (*Manager) GetTransactionInclusionProof ¶
func (m *Manager) GetTransactionInclusionProof(transactionID utxo.TransactionID) (*CommitmentProof, error)
GetTransactionInclusionProof gets the proof of the inclusion (acceptance) of a transaction.
func (*Manager) LatestConfirmedEpochIndex ¶
LatestConfirmedEpochIndex returns the latest epoch index that has been confirmed.
func (*Manager) LoadSnapshot ¶
LoadSnapshot initiates the state and mana trees from a given snapshot.
func (*Manager) OnAcceptanceTimeUpdated ¶
OnAcceptanceTimeUpdated is the handler for time updated event and triggers the events.
func (*Manager) OnBlockAccepted ¶
OnBlockAccepted is the handler for block confirmed event.
func (*Manager) OnBlockOrphaned ¶
OnBlockOrphaned is the handler for block orphaned event.
func (*Manager) OnConflictConfirmed ¶
func (m *Manager) OnConflictConfirmed(conflictID utxo.TransactionID)
OnConflictConfirmed is the handler for conflict confirmed event.
func (*Manager) OnConflictCreated ¶
func (m *Manager) OnConflictCreated(conflictID utxo.TransactionID)
OnConflictCreated is the handler for conflict created event.
func (*Manager) OnConflictRejected ¶
func (m *Manager) OnConflictRejected(conflictID utxo.TransactionID)
OnConflictRejected is the handler for conflict created event.
func (*Manager) OnTransactionAccepted ¶
func (m *Manager) OnTransactionAccepted(event *ledger.TransactionAcceptedEvent)
OnTransactionAccepted is the handler for transaction accepted event.
func (*Manager) OnTransactionInclusionUpdated ¶
func (m *Manager) OnTransactionInclusionUpdated(event *ledger.TransactionInclusionUpdatedEvent)
OnTransactionInclusionUpdated is the handler for transaction inclusion updated event.
func (*Manager) PendingConflictsCount ¶
PendingConflictsCount returns the current value of pendingConflictsCount.
func (*Manager) PendingConflictsCountAll ¶
PendingConflictsCountAll returns the current value of pendingConflictsCount per epoch.
type ManagerOption ¶
type ManagerOption func(options *ManagerOptions)
ManagerOption represents the return type of the optional config parameters of the notarization manager.
func BootstrapWindow ¶
func BootstrapWindow(d time.Duration) ManagerOption
BootstrapWindow specifies when the notarization manager is considered to be bootstrapped.
func ManaDelay ¶
func ManaDelay(d uint) ManagerOption
ManaDelay specifies the epoch offset for mana vector from the last committable epoch.
func MinCommittableEpochAge ¶
func MinCommittableEpochAge(d time.Duration) ManagerOption
MinCommittableEpochAge specifies how old an epoch has to be for it to be committable.
type ManagerOptions ¶
type ManagerOptions struct {
MinCommittableEpochAge time.Duration
BootstrapWindow time.Duration
ManaEpochDelay uint
Log *logger.Logger
}
ManagerOptions is a container of all the config parameters of the notarization manager.
type Option ¶
type Option func(*options)
Option represents the return type of optional parameters that can be handed into the constructor of the EpochStateDiffStorage to configure its behavior.
type StateMutationTreeUpdatedEvent ¶
type StateMutationTreeUpdatedEvent struct {
// EI is the index of the transaction.
EI epoch.Index
// TransactionID is the transaction ID that inserted/removed to/from the state mutation smt.
TransactionID utxo.TransactionID
}
StateMutationTreeUpdatedEvent is a container that acts as a dictionary for the State mutation tree inserted/removed event related parameters.
type TangleTreeUpdatedEvent ¶
type TangleTreeUpdatedEvent struct {
// EI is the index of the block.
EI epoch.Index
// BlockID is the blockID that inserted/removed to/from the tangle smt.
BlockID tangle.BlockID
}
TangleTreeUpdatedEvent is a container that acts as a dictionary for the TangleTree inserted/removed event related parameters.
type UTXOUpdatedEvent ¶
type UTXOUpdatedEvent struct {
// EI is the index of updated UTXO.
EI epoch.Index
// Created are the outputs created in a transaction.
Created []*ledger.OutputWithMetadata
// Spent are outputs that is spent in a transaction.
Spent []*ledger.OutputWithMetadata
}
UTXOUpdatedEvent is a container that acts as a dictionary for the UTXO update event related parameters.