tangle

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var (
	ErrMilestoneNotFound = errors.New("milestone not found")
	ErrDivisionByZero    = errors.New("division by zero")
)

Functions

func AddMessageToStorage added in v1.1.0

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 added in v1.2.0

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 ConfirmedMilestoneMetric

type ConfirmedMilestoneMetric struct {
	MilestoneIndex         milestone.Index `json:"ms_index"`
	MPS                    float64         `json:"mps"`
	RMPS                   float64         `json:"rmps"`
	ReferencedRate         float64         `json:"referenced_rate"`
	TimeSinceLastMilestone float64         `json:"time_since_last_ms"`
}

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

type FutureConeSolidifier struct {
	syncutils.Mutex
	// contains filtered or unexported fields
}

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) 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 MPSMetrics struct {
	Incoming uint32 `json:"incoming"`
	New      uint32 `json:"new"`
	Outgoing uint32 `json:"outgoing"`
}

type MarkMessageAsSolidFunc added in v1.2.0

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

func (t *Tangle) DeregisterMessageProcessedEvent(messageID hornet.MessageID)

DeregisterMessageProcessedEvent removes a registered event to free the memory if not used.

func (*Tangle) DeregisterMessageSolidEvent

func (t *Tangle) DeregisterMessageSolidEvent(messageID hornet.MessageID)

DeregisterMessageSolidEvent removes a registered event to free the memory if not used.

func (*Tangle) DeregisterMilestoneConfirmedEvent

func (t *Tangle) DeregisterMilestoneConfirmedEvent(msIndex milestone.Index)

DeregisterMilestoneConfirmedEvent removes a registered event to free the memory if not used.

func (*Tangle) IsNodeHealthy

func (t *Tangle) IsNodeHealthy() bool

IsNodeHealthy returns whether the node is synced, has active neighbors and its latest milestone is not too old.

func (*Tangle) IsReceiveTxWorkerPoolBusy

func (t *Tangle) IsReceiveTxWorkerPoolBusy() bool

func (*Tangle) LastConfirmedMilestoneMetric

func (t *Tangle) LastConfirmedMilestoneMetric() *ConfirmedMilestoneMetric

func (*Tangle) PrintStatus

func (t *Tangle) PrintStatus()

func (*Tangle) RegisterMessageProcessedEvent

func (t *Tangle) RegisterMessageProcessedEvent(messageID hornet.MessageID) chan struct{}

RegisterMessageProcessedEvent returns a channel that gets closed when the message is processed.

func (*Tangle) RegisterMessageSolidEvent

func (t *Tangle) RegisterMessageSolidEvent(messageID hornet.MessageID) chan struct{}

RegisterMessageSolidEvent returns a channel that gets closed when the message is marked as solid.

func (*Tangle) RegisterMilestoneConfirmedEvent

func (t *Tangle) RegisterMilestoneConfirmedEvent(msIndex milestone.Index) chan struct{}

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

func (t *Tangle) SetUpdateSyncedAtStartup(updateSyncedAtStartup bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL