Documentation ¶
Index ¶
- Variables
- func AddMessageToStorage(dbStorage *storage.Storage, ...) (cachedMsg *storage.CachedMessage, alreadyAdded bool)
- func ConfirmationMetricsCaller(handler interface{}, params ...interface{})
- func ConfirmedMilestoneCaller(handler interface{}, params ...interface{})
- func LedgerUpdatedCaller(handler interface{}, params ...interface{})
- func MPSMetricsCaller(handler interface{}, params ...interface{})
- func NewConfirmedMilestoneMetricCaller(handler interface{}, params ...interface{})
- func ReceiptCaller(handler interface{}, params ...interface{})
- func UTXOOutputCaller(handler interface{}, params ...interface{})
- func UTXOSpentCaller(handler interface{}, params ...interface{})
- type ConfirmedMilestoneMetric
- type Events
- type FutureConeSolidifier
- func (s *FutureConeSolidifier) Cleanup(forceRelease bool)
- func (s *FutureConeSolidifier) SolidifyDirectChildrenWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, ...) error
- func (s *FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, ...) error
- func (s *FutureConeSolidifier) SolidifyMessageAndFutureCone(ctx context.Context, cachedMsgMeta *storage.CachedMetadata) error
- type MPSMetrics
- type MarkMessageAsSolidFunc
- type Tangle
- func (t *Tangle) AbortMilestoneSolidification()
- func (t *Tangle) ConfigureTangleProcessor()
- func (t *Tangle) DeregisterMessageProcessedEvent(messageID hornet.MessageID)
- func (t *Tangle) DeregisterMessageSolidEvent(messageID hornet.MessageID)
- func (t *Tangle) DeregisterMilestoneConfirmedEvent(msIndex milestone.Index)
- func (t *Tangle) IsNodeHealthy(sync ...*syncmanager.SyncState) bool
- func (t *Tangle) IsReceiveTxWorkerPoolBusy() bool
- func (t *Tangle) LastConfirmedMilestoneMetric() *ConfirmedMilestoneMetric
- func (t *Tangle) PrintStatus()
- func (t *Tangle) RegisterMessageProcessedEvent(messageID hornet.MessageID) chan struct{}
- func (t *Tangle) RegisterMessageSolidEvent(messageID hornet.MessageID) chan struct{}
- func (t *Tangle) RegisterMilestoneConfirmedEvent(msIndex milestone.Index) chan struct{}
- func (t *Tangle) ResetMilestoneTimeoutTicker()
- func (t *Tangle) RevalidateDatabase(snapshotManager *snapshot.SnapshotManager, 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()
Constants ¶
This section is empty.
Variables ¶
var ( ErrSnapshotInfoMissing = errors.New("snapshot information not found in database") 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 (
ErrDivisionByZero = errors.New("division by zero")
)
Functions ¶
func AddMessageToStorage ¶
func AddMessageToStorage(dbStorage *storage.Storage, milestoneManager *milestonemanager.MilestoneManager, message *storage.Message, latestMilestoneIndex milestone.Index, requested bool, forceRelease bool) (cachedMsg *storage.CachedMessage, alreadyAdded bool)
AddMessageToStorage adds a new message to the cache/persistence layer, including all additional information like metadata, children, indexation, unreferenced messages and milestone entries. message +1
func ConfirmationMetricsCaller ¶
func ConfirmationMetricsCaller(handler interface{}, params ...interface{})
ConfirmationMetricsCaller is used to signal updated confirmation metrics.
func ConfirmedMilestoneCaller ¶
func ConfirmedMilestoneCaller(handler interface{}, params ...interface{})
func LedgerUpdatedCaller ¶
func LedgerUpdatedCaller(handler interface{}, params ...interface{})
func MPSMetricsCaller ¶
func MPSMetricsCaller(handler interface{}, params ...interface{})
func NewConfirmedMilestoneMetricCaller ¶
func NewConfirmedMilestoneMetricCaller(handler interface{}, params ...interface{})
func ReceiptCaller ¶
func ReceiptCaller(handler interface{}, params ...interface{})
func UTXOOutputCaller ¶
func UTXOOutputCaller(handler interface{}, params ...interface{})
func UTXOSpentCaller ¶
func UTXOSpentCaller(handler interface{}, params ...interface{})
Types ¶
type Events ¶
type Events struct { MPSMetricsUpdated *events.Event ReceivedNewMessage *events.Event ReceivedKnownMessage *events.Event ProcessedMessage *events.Event MessageSolid *events.Event MessageReferenced *events.Event ReceivedNewMilestone *events.Event LatestMilestoneChanged *events.Event LatestMilestoneIndexChanged *events.Event MilestoneConfirmed *events.Event ConfirmedMilestoneChanged *events.Event ConfirmedMilestoneIndexChanged *events.Event NewConfirmedMilestoneMetric *events.Event ConfirmationMetricsUpdated *events.Event MilestoneSolidificationFailed *events.Event MilestoneTimeout *events.Event LedgerUpdated *events.Event NewUTXOOutput *events.Event NewUTXOSpent *events.Event NewReceipt *events.Event }
type FutureConeSolidifier ¶
FutureConeSolidifier traverses the future cone of messages 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, markMessageAsSolidFunc MarkMessageAsSolidFunc) *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) SolidifyDirectChildrenWithMetadataMemcache ¶
func (s *FutureConeSolidifier) SolidifyDirectChildrenWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, messageIDs hornet.MessageIDs) error
SolidifyDirectChildrenWithMetadataMemcache updates the solidity of the direct children of the given messages. The given messages itself must already be solid, otherwise an error is returned. 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.
func (*FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache ¶
func (s *FutureConeSolidifier) SolidifyFutureConesWithMetadataMemcache(ctx context.Context, memcachedTraverserStorage dag.TraverserStorage, messageIDs hornet.MessageIDs) error
SolidifyFutureConesWithMetadataMemcache updates the solidity of the given messages and their future cones (messages approving the given messages). 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.
func (*FutureConeSolidifier) SolidifyMessageAndFutureCone ¶
func (s *FutureConeSolidifier) SolidifyMessageAndFutureCone(ctx context.Context, cachedMsgMeta *storage.CachedMetadata) error
SolidifyMessageAndFutureCone updates the solidity of the message and its future cone (messages approving the given message). We keep on walking the future cone, if a message became newly solid during the walk.
type MPSMetrics ¶
type MarkMessageAsSolidFunc ¶
type MarkMessageAsSolidFunc func(*storage.CachedMetadata)
type Tangle ¶
type Tangle struct { // the logger used to log events. *utils.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, belowMaxDepth int, milestoneTimeout time.Duration, updateSyncedAtStartup bool) *Tangle
func (*Tangle) AbortMilestoneSolidification ¶
func (t *Tangle) AbortMilestoneSolidification()
func (*Tangle) ConfigureTangleProcessor ¶
func (t *Tangle) ConfigureTangleProcessor()
func (*Tangle) DeregisterMessageProcessedEvent ¶
DeregisterMessageProcessedEvent removes a registered event to free the memory if not used.
func (*Tangle) DeregisterMessageSolidEvent ¶
DeregisterMessageSolidEvent removes a registered event to free the memory if not used.
func (*Tangle) DeregisterMilestoneConfirmedEvent ¶
DeregisterMilestoneConfirmedEvent removes a registered event to free the memory if not used.
func (*Tangle) IsNodeHealthy ¶
func (t *Tangle) IsNodeHealthy(sync ...*syncmanager.SyncState) bool
IsNodeHealthy returns whether the node is synced, has active neighbors 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) RegisterMessageProcessedEvent ¶
RegisterMessageProcessedEvent returns a channel that gets closed when the message is processed.
func (*Tangle) RegisterMessageSolidEvent ¶
RegisterMessageSolidEvent returns a channel that gets closed when the message is marked as solid.
func (*Tangle) RegisterMilestoneConfirmedEvent ¶
RegisterMilestoneConfirmedEvent returns a channel that gets closed when the milestone is confirmed.
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 ¶
func (t *Tangle) RevalidateDatabase(snapshotManager *snapshot.SnapshotManager, pruneReceipts bool) error
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 messages 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 msg
- Message => will be removed and added again by requesting the msg at solidification
- MessageMetadata => will be removed and added again if missing by receiving the msg
- Children => will be removed and added again if missing by receiving the msg
- Indexation => will be removed and added again if missing by receiving the msg
- UnreferencedMessage => 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 milestone.Index, parents hornet.MessageIDs) (solid bool, aborted bool)
SolidQueueCheck traverses a milestone and checks if it is solid. Missing messages 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.