Documentation ¶
Index ¶
- Constants
- Variables
- func AddBlockToStorage(dbStorage *storage.Storage, ...) (cachedBlock *storage.CachedBlock, alreadyAdded bool)
- func BPSMetricsCaller(handler interface{}, params ...interface{})
- func ConfirmationMetricsCaller(handler interface{}, params ...interface{})
- func LedgerUpdatedCaller(handler interface{}, params ...interface{})
- func ReceiptCaller(handler interface{}, params ...interface{})
- func ReferencedBlocksCountUpdatedCaller(handler interface{}, params ...interface{})
- func TreasuryMutationCaller(handler interface{}, params ...interface{})
- type BPSMetrics
- type BlockAttacher
- type BlockAttacherOption
- type BlockAttacherOptions
- type ConfirmedMilestoneMetric
- type Events
- type FutureConeSolidifier
- func (s *FutureConeSolidifier) Cleanup(forceRelease bool)
- func (s *FutureConeSolidifier) SolidifyBlockAndFutureCone(ctx context.Context, cachedBlockMeta *storage.CachedMetadata) error
- func (s *FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, ...) error
- type MarkBlockAsSolidFunc
- type Tangle
- func (t *Tangle) AbortMilestoneSolidification()
- func (t *Tangle) BlockAttacher(opts ...BlockAttacherOption) *BlockAttacher
- func (t *Tangle) CheckSolidityAndComputeWhiteFlagMutations(ctx context.Context, index iotago.MilestoneIndex, timestamp uint32, ...) (*whiteflag.WhiteFlagMutations, error)
- func (t *Tangle) ConfigureTangleProcessor()
- func (t *Tangle) DeregisterBlockProcessedEvent(blockID iotago.BlockID)
- func (t *Tangle) DeregisterBlockSolidEvent(blockID iotago.BlockID)
- func (t *Tangle) IsNodeHealthy() bool
- func (t *Tangle) IsReceiveTxWorkerPoolBusy() bool
- func (t *Tangle) LastConfirmedMilestoneMetric() *ConfirmedMilestoneMetric
- func (t *Tangle) PrintStatus()
- func (t *Tangle) RegisterBlockProcessedEvent(blockID iotago.BlockID) chan struct{}
- func (t *Tangle) RegisterBlockSolidEvent(blockID iotago.BlockID) chan struct{}
- func (t *Tangle) ResetMilestoneTimeoutTicker()
- func (t *Tangle) RevalidateDatabase(snapshotImporter *snapshot.Importer, pruneReceipts bool) error
- func (t *Tangle) RunTangleProcessor()
- func (t *Tangle) SetUpdateSyncedAtStartup(updateSyncedAtStartup bool)
- func (t *Tangle) SolidQueueCheck(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, ...) (solid bool, aborted bool)
- func (t *Tangle) StopMilestoneTimeoutTicker()
- func (t *Tangle) TriggerSolidifier()
- func (t *Tangle) WaitForTangleProcessorStartup()
- type TipScore
- type TipScoreCalculator
Constants ¶
const (
SolidifierTriggerSignal = iotago.MilestoneIndex(0)
)
Variables ¶
var ( ErrBlockAttacherInvalidBlock = errors.New("invalid block") ErrBlockAttacherAttachingNotPossible = errors.New("attaching not possible") ErrBlockAttacherPoWNotAvailable = errors.New("proof of work is not available on this node") )
var ( ErrLatestMilestoneOlderThanSnapshotIndex = errors.New("latest milestone in the database is older than the snapshot index") ErrSnapshotIndexWrong = errors.New("snapshot index does not fit the snapshot ledger index") )
var ( ErrParentsNotGiven = errors.New("no parents given") ErrParentsNotSolid = errors.New("parents not solid") )
var (
ErrDivisionByZero = errors.New("division by zero")
)
Functions ¶
func AddBlockToStorage ¶
func AddBlockToStorage(dbStorage *storage.Storage, milestoneManager *milestonemanager.MilestoneManager, block *storage.Block, latestMilestoneIndex iotago.MilestoneIndex, requested bool, forceRelease bool) (cachedBlock *storage.CachedBlock, alreadyAdded bool)
AddBlockToStorage adds a new block to the cache/persistence layer, including all additional information like metadata, children, unreferenced blocks and milestone entries. block +1
func BPSMetricsCaller ¶
func BPSMetricsCaller(handler interface{}, params ...interface{})
func ConfirmationMetricsCaller ¶
func ConfirmationMetricsCaller(handler interface{}, params ...interface{})
ConfirmationMetricsCaller is used to signal updated confirmation metrics.
func LedgerUpdatedCaller ¶
func LedgerUpdatedCaller(handler interface{}, params ...interface{})
func ReceiptCaller ¶
func ReceiptCaller(handler interface{}, params ...interface{})
func ReferencedBlocksCountUpdatedCaller ¶
func ReferencedBlocksCountUpdatedCaller(handler interface{}, params ...interface{})
func TreasuryMutationCaller ¶
func TreasuryMutationCaller(handler interface{}, params ...interface{})
Types ¶
type BPSMetrics ¶
type BlockAttacher ¶
type BlockAttacher struct {
// contains filtered or unexported fields
}
func (*BlockAttacher) AttachBlock ¶
type BlockAttacherOption ¶
type BlockAttacherOption func(opts *BlockAttacherOptions)
func WithPoWMetrics ¶
func WithPoWMetrics(powMetrics metrics.PoWMetrics) BlockAttacherOption
func WithTimeout ¶
func WithTimeout(blockProcessedTimeout time.Duration) BlockAttacherOption
func WithTipSel ¶
func WithTipSel(tipsFunc pow.RefreshTipsFunc) BlockAttacherOption
type BlockAttacherOptions ¶
type BlockAttacherOptions struct {
// contains filtered or unexported fields
}
type Events ¶
type Events struct { // block events ReceivedNewBlock *events.Event BlockSolid *events.Event ReceivedNewMilestoneBlock *events.Event // remove with dashboard removal PR // milestone events LatestMilestoneChanged *events.Event LatestMilestoneIndexChanged *events.Event MilestoneSolidificationFailed *events.Event MilestoneTimeout *events.Event // metrics BPSMetricsUpdated *events.Event // Hint: Ledger is write locked ConfirmedMilestoneIndexChanged *events.Event // Hint: Ledger is not locked ConfirmationMetricsUpdated *events.Event // used for prometheus metrics // Hint: Ledger is not locked ConfirmedMilestoneChanged *events.Event // Hint: Ledger is not locked BlockReferenced *events.Event // Hint: Ledger is not locked ReferencedBlocksCountUpdated *events.Event // Hint: Ledger is not locked LedgerUpdated *events.Event // Hint: Ledger is not locked TreasuryMutated *events.Event // Hint: Ledger is not locked NewReceipt *events.Event }
type FutureConeSolidifier ¶
FutureConeSolidifier traverses the future cone of blocks and updates their solidity. It holds a reference to a traverser and a memcache, so that these can be reused for "gossip solidifcation".
func NewFutureConeSolidifier ¶
func NewFutureConeSolidifier(dbStorage *storage.Storage, markBlockAsSolidFunc MarkBlockAsSolidFunc) *FutureConeSolidifier
NewFutureConeSolidifier creates a new FutureConeSolidifier instance.
func (*FutureConeSolidifier) Cleanup ¶
func (s *FutureConeSolidifier) Cleanup(forceRelease bool)
Cleanup releases all the currently cached objects that have been traversed. This SHOULD be called periodically to free the caches (e.g. with every change of the latest known milestone index).
func (*FutureConeSolidifier) SolidifyBlockAndFutureCone ¶
func (s *FutureConeSolidifier) SolidifyBlockAndFutureCone(ctx context.Context, cachedBlockMeta *storage.CachedMetadata) error
SolidifyBlockAndFutureCone updates the solidity of the block and its future cone (blocks approving the given block). We keep on walking the future cone, if a block became newly solid during the walk.
func (*FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache ¶
func (s *FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, blockIDs iotago.BlockIDs) error
SolidifyFutureConesWithMetadataMemcache updates the solidity of the given blocks and their future cones (blocks approving the given blocks). This function doesn't use the same memcache nor traverser like the FutureConeSolidifier, but it holds the lock, so no other solidifications are done in parallel.
type MarkBlockAsSolidFunc ¶
type MarkBlockAsSolidFunc func(*storage.CachedMetadata)
type Tangle ¶
type Tangle struct { // the logger used to log events. *logger.WrappedLogger Events *Events // contains filtered or unexported fields }
func New ¶
func New( log *logger.Logger, daemon daemon.Daemon, shutdownCtx context.Context, dbStorage *storage.Storage, syncManager *syncmanager.SyncManager, milestoneManager *milestonemanager.MilestoneManager, requestQueue gossip.RequestQueue, gossipService *gossip.Service, messageProcessor *gossip.MessageProcessor, serverMetrics *metrics.ServerMetrics, requester *gossip.Requester, receiptService *migrator.ReceiptService, protocolManager *protocol.Manager, milestoneTimeout time.Duration, whiteFlagParentsSolidTimeout time.Duration, updateSyncedAtStartup bool) *Tangle
func (*Tangle) AbortMilestoneSolidification ¶
func (t *Tangle) AbortMilestoneSolidification()
func (*Tangle) BlockAttacher ¶
func (t *Tangle) BlockAttacher(opts ...BlockAttacherOption) *BlockAttacher
func (*Tangle) CheckSolidityAndComputeWhiteFlagMutations ¶
func (t *Tangle) CheckSolidityAndComputeWhiteFlagMutations(ctx context.Context, index iotago.MilestoneIndex, timestamp uint32, parents iotago.BlockIDs, previousMilestoneID iotago.MilestoneID) (*whiteflag.WhiteFlagMutations, error)
CheckSolidityAndComputeWhiteFlagMutations waits until all given parents are solid, an then calculates the white flag mutations with given milestone index, timestamp and previousMilestoneID. Attention: this call puts missing parents of the cone as undiscardable requests into the request queue. Therefore the caller needs to be trustful (e.g. coordinator plugin).
func (*Tangle) ConfigureTangleProcessor ¶
func (t *Tangle) ConfigureTangleProcessor()
func (*Tangle) DeregisterBlockProcessedEvent ¶
DeregisterBlockProcessedEvent removes a registered event to free the memory if not used.
func (*Tangle) DeregisterBlockSolidEvent ¶
DeregisterBlockSolidEvent removes a registered event to free the memory if not used.
func (*Tangle) IsNodeHealthy ¶
IsNodeHealthy returns whether the node is synced, has active peers and its latest milestone is not too old.
func (*Tangle) IsReceiveTxWorkerPoolBusy ¶
func (*Tangle) LastConfirmedMilestoneMetric ¶
func (t *Tangle) LastConfirmedMilestoneMetric() *ConfirmedMilestoneMetric
func (*Tangle) PrintStatus ¶
func (t *Tangle) PrintStatus()
func (*Tangle) RegisterBlockProcessedEvent ¶
RegisterBlockProcessedEvent returns a channel that gets closed when the block is processed.
func (*Tangle) RegisterBlockSolidEvent ¶
RegisterBlockSolidEvent returns a channel that gets closed when the block is marked as solid.
func (*Tangle) ResetMilestoneTimeoutTicker ¶
func (t *Tangle) ResetMilestoneTimeoutTicker()
ResetMilestoneTimeoutTicker stops a running milestone timeout ticker and starts a new one. MilestoneTimeout event is fired periodically if ResetMilestoneTimeoutTicker is not called within milestoneTimeout.
func (*Tangle) RevalidateDatabase ¶
RevalidateDatabase tries to revalidate a corrupted database (after an unclean node shutdown/crash)
HORNET uses caches for almost all tangle related data. If the node crashes, it is not guaranteed that all data in the cache was already persisted to the disk. Thats why we flag the database as corrupted.
This function tries to restore a clean database state by deleting all existing blocks since last local snapshot, deleting all ledger states and changes, and loading a valid snapshot ledger state.
This way HORNET should be able to re-solidify the existing tangle in the database.
Object Storages:
- Milestone => will be removed and added again if missing by receiving the block
- Block => will be removed and added again by requesting the block at solidification
- BlockMetadata => will be removed and added again if missing by receiving the block
- Children => will be removed and added again if missing by receiving the block
- Indexation => will be removed and added again if missing by receiving the block
- UnreferencedBlock => will be removed at pruning anyway
Database:
- LedgerState
- Unspent => will be removed and loaded again from last snapshot
- Spent => will be removed and loaded again from last snapshot
- Balances => will be removed and loaded again from last snapshot
- Diffs => will be removed and loaded again from last snapshot
- Treasury => will be removed and loaded again from last snapshot
- Receipts => will be removed and loaded again from last snapshot (if pruneReceipts is enabled)
func (*Tangle) RunTangleProcessor ¶
func (t *Tangle) RunTangleProcessor()
func (*Tangle) SetUpdateSyncedAtStartup ¶
SetUpdateSyncedAtStartup sets the flag if the isNodeSynced status should be updated at startup
func (*Tangle) SolidQueueCheck ¶
func (t *Tangle) SolidQueueCheck( ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, milestoneIndex iotago.MilestoneIndex, parents iotago.BlockIDs) (solid bool, aborted bool)
SolidQueueCheck traverses a milestone and checks if it is solid. Missing blocks are requested. Can be aborted if the given context is canceled.
func (*Tangle) StopMilestoneTimeoutTicker ¶
func (t *Tangle) StopMilestoneTimeoutTicker()
StopMilestoneTimeoutTicker stops the milestone timeout ticker.
func (*Tangle) TriggerSolidifier ¶
func (t *Tangle) TriggerSolidifier()
TriggerSolidifier can be used to manually trigger the solidifier from other plugins.
func (*Tangle) WaitForTangleProcessorStartup ¶
func (t *Tangle) WaitForTangleProcessorStartup()
WaitForTangleProcessorStartup waits until all background workers of the tangle processor are started.
type TipScoreCalculator ¶
type TipScoreCalculator struct {
// contains filtered or unexported fields
}