tangle

package
v0.7.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2021 License: Apache-2.0, BSD-2-Clause Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessageVersion defines the version of the message structure.
	MessageVersion uint8 = 1

	// MaxMessageSize defines the maximum size of a message.
	MaxMessageSize = 64 * 1024

	// MessageIDLength defines the length of an MessageID.
	MessageIDLength = 32

	// StrongParent identifies a strong parent in the bitmask.
	StrongParent uint8 = 1

	// WeakParent identifies a weak parent in the bitmask.
	WeakParent uint8 = 0

	// MinParentsCount defines the minimum number of parents a message must have.
	MinParentsCount = 1

	// MaxParentsCount defines the maximum number of parents a message must have.
	MaxParentsCount = 8

	// MinStrongParentsCount defines the minimum number of strong parents a message must have.
	MinStrongParentsCount = 1
)
View Source
const (
	// MaxLocalQueueSize is the maximum local (containing the message to be issued) queue size in bytes
	MaxLocalQueueSize = 20 * MaxMessageSize
	// Backoff is the local threshold for rate setting; < MaxQueueWeight
	Backoff = 25.0
	// RateSettingIncrease is the global additive increase parameter.
	RateSettingIncrease = 1.0
	// RateSettingDecrease global multiplicative decrease parameter  (larger than 1)
	RateSettingDecrease = 1.5
	// RateSettingPause is the time to wait before next rate's update after a backoff
	RateSettingPause = 2
)
View Source
const (
	// MaxDeficit is the maximum cap for accumulated deficit, i.e. max bytes that can be scheduled without waiting.
	// It must be >= MaxMessageSize.
	MaxDeficit = MaxMessageSize
	// MinMana is the minimum amount of Mana needed to issue messages.
	// MaxMessageSize / MinMana is also the upper bound of iterations inside one schedule call, as such it should not be too small.
	MinMana float64 = 1.0
)
View Source
const (
	// PrefixMessage defines the storage prefix for message.
	PrefixMessage byte = iota

	// PrefixMessageMetadata defines the storage prefix for message metadata.
	PrefixMessageMetadata

	// PrefixApprovers defines the storage prefix for approvers.
	PrefixApprovers

	// PrefixMissingMessage defines the storage prefix for missing message.
	PrefixMissingMessage

	// PrefixAttachments defines the storage prefix for attachments.
	PrefixAttachments

	// PrefixMarkerBranchIDMapping defines the storage prefix for the PrefixMarkerBranchIDMapping.
	PrefixMarkerBranchIDMapping

	// PrefixIndividuallyMappedMessage defines the storage prefix for the IndividuallyMappedMessage.
	PrefixIndividuallyMappedMessage

	// PrefixSequenceSupporters defines the storage prefix for the SequenceSupporters.
	PrefixSequenceSupporters

	// PrefixBranchSupporters defines the storage prefix for the BranchSupporters.
	PrefixBranchSupporters

	// PrefixStatement defines the storage prefix for the Statement.
	PrefixStatement

	// PrefixBranchWeight defines the storage prefix for the BranchWeight.
	PrefixBranchWeight

	// PrefixMarkerMessageMapping defines the storage prefix for the MarkerMessageMapping.
	PrefixMarkerMessageMapping

	// DBSequenceNumber defines the db sequence number.
	DBSequenceNumber = "seq"
)
View Source
const (
	// DefaultGenesisTime is the default time (Unix in seconds) of the genesis, i.e., the start of the epochs at 2021-03-19 9:00:00 UTC.
	DefaultGenesisTime int64 = 1616144400
	// DefaultSyncTimeWindow is the default sync time window.
	DefaultSyncTimeWindow = 2 * time.Minute
)
View Source
const ApproverTypeLength = 1

ApproverTypeLength contains the amount of bytes that a marshaled version of the ApproverType contains.

AttachmentLength holds the length of a marshaled Attachment in bytes.

View Source
const (
	// DefaultRetryInterval defines the Default Retry Interval of the message requester.
	DefaultRetryInterval = 10 * time.Second
)
View Source
const (
	// MaxReattachmentTimeMin defines the max reattachment time.
	MaxReattachmentTimeMin = 10 * time.Minute
)

Variables

View Source
var (
	// ErrNotSynced is triggered when somebody tries to issue a Payload before the Tangle is fully synced.
	ErrNotSynced = errors.New("tangle not synced")
	// ErrInvalidInputs is returned when one or more inputs are rejected or non-monotonically liked.
	ErrInvalidInputs = errors.New("one or more inputs are rejected or non-monotonically liked")
	// ErrParentsInvalid is returned when one or more parents of a message is invalid.
	ErrParentsInvalid = errors.New("one or more parents is invalid")
)
View Source
var (
	// ErrInvalidPOWDifficultly is returned when the nonce of a message does not fulfill the PoW difficulty.
	ErrInvalidPOWDifficultly = errors.New("invalid PoW")

	// ErrMessageTooSmall is returned when the message does not contain enough data for the PoW.
	ErrMessageTooSmall = errors.New("message too small")

	// ErrInvalidSignature is returned when a message contains an invalid signature.
	ErrInvalidSignature = fmt.Errorf("invalid signature")

	// ErrReceivedDuplicateBytes is returned when duplicated bytes are rejected.
	ErrReceivedDuplicateBytes = fmt.Errorf("received duplicate bytes")

	// ErrInvalidMessageAndTransactionTimestamp is returned when the message its transaction timestamps are invalid.
	ErrInvalidMessageAndTransactionTimestamp = fmt.Errorf("invalid message and transaction timestamp")
)
View Source
var (
	// ErrInvalidIssuer is returned when an invalid message is passed to the rate setter.
	ErrInvalidIssuer = errors.New("message not issued by local node")
	// ErrStopped is returned when a message is passed to a stopped rate setter.
	ErrStopped = errors.New("rate setter stopped")
)
View Source
var EmptyMessageID = MessageID{}

EmptyMessageID is an empty id.

View Source
var ErrNotRunning = errors.New("scheduler stopped")

ErrNotRunning is returned when a message is submitted when the scheduler has been stopped

View Source
var IndividuallyMappedMessagePartitionKeys = objectstorage.PartitionKey([]int{ledgerstate.BranchIDLength, MessageIDLength}...)

IndividuallyMappedMessagePartitionKeys defines the "layout" of the key. This enables prefix iterations in the object storage.

View Source
var Initial = 20000.0

Initial is the rate in bytes per second

MarkerMessageMappingPartitionKeys defines the "layout" of the key. This enables prefix iterations in the object storage.

View Source
var ZeroWorker = WorkerFunc(func([]byte) (uint64, error) { return 0, nil })

ZeroWorker is a PoW worker that always returns 0 as the nonce.

Functions

func ApproverFromObjectStorage

func ApproverFromObjectStorage(key []byte, _ []byte) (result objectstorage.StorableObject, err error)

ApproverFromObjectStorage is the factory method for Approvers stored in the ObjectStorage.

func AttachmentFromObjectStorage added in v0.3.6

func AttachmentFromObjectStorage(key []byte, _ []byte) (result objectstorage.StorableObject, err error)

AttachmentFromObjectStorage gets called when we restore an Attachment from the storage - it parses the key bytes and returns the new object.

func BranchSupportersFromObjectStorage added in v0.5.7

func BranchSupportersFromObjectStorage(key, data []byte) (result objectstorage.StorableObject, err error)

BranchSupportersFromObjectStorage restores a BranchSupporters object from the object storage.

func BranchWeightFromObjectStorage added in v0.5.7

func BranchWeightFromObjectStorage(key, data []byte) (result objectstorage.StorableObject, err error)

BranchWeightFromObjectStorage restores a BranchWeight object from the object storage.

func IndividuallyMappedMessageFromObjectStorage added in v0.5.7

func IndividuallyMappedMessageFromObjectStorage(key, value []byte) (result objectstorage.StorableObject, err error)

IndividuallyMappedMessageFromObjectStorage is a factory method that creates a new IndividuallyMappedMessage instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func MarkerIndexBranchIDMappingFromObjectStorage added in v0.3.6

func MarkerIndexBranchIDMappingFromObjectStorage(key []byte, data []byte) (markerIndexBranchIDMapping objectstorage.StorableObject, err error)

MarkerIndexBranchIDMappingFromObjectStorage restores a MarkerIndexBranchIDMapping that was stored in the object storage.

func MarkerMessageMappingFromObjectStorage added in v0.5.7

func MarkerMessageMappingFromObjectStorage(key, value []byte) (result objectstorage.StorableObject, err error)

MarkerMessageMappingFromObjectStorage is a factory method that creates a new MarkerMessageMapping instance from a storage key of the object storage. It is used by the object storage, to create new instances of this entity.

func MessageCaller added in v0.6.0

func MessageCaller(handler interface{}, params ...interface{})

MessageCaller is the caller function for events that hand over a Message.

func MessageFromObjectStorage

func MessageFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)

MessageFromObjectStorage restores a Message from the ObjectStorage.

func MessageIDCaller added in v0.5.0

func MessageIDCaller(handler interface{}, params ...interface{})

MessageIDCaller is the caller function for events that hand over a MessageID.

func MessageInvalidCaller added in v0.7.6

func MessageInvalidCaller(handler interface{}, params ...interface{})

MessageInvalidCaller is the caller function for events that had over an invalid message.

func MessageMetadataFromObjectStorage

func MessageMetadataFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)

MessageMetadataFromObjectStorage restores a MessageMetadata object from the ObjectStorage.

func MissingMessageFromObjectStorage

func MissingMessageFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)

MissingMessageFromObjectStorage restores a MissingMessage from the ObjectStorage.

func NodeIDCaller added in v0.6.2

func NodeIDCaller(handler interface{}, params ...interface{})

NodeIDCaller is the caller function for events that hand over a NodeID.

func RegisterMessageIDAlias added in v0.5.7

func RegisterMessageIDAlias(messageID MessageID, alias string)

RegisterMessageIDAlias registers an alias that will modify the String() output of the MessageID to show a human readable string instead of the base58 encoded version of itself.

func SequenceSupportersFromObjectStorage added in v0.5.7

func SequenceSupportersFromObjectStorage(key, data []byte) (result objectstorage.StorableObject, err error)

SequenceSupportersFromObjectStorage restores a SequenceSupporters object from the object storage.

func StatementFromObjectStorage added in v0.5.7

func StatementFromObjectStorage(key, data []byte) (result objectstorage.StorableObject, err error)

StatementFromObjectStorage restores a Statement object from the object storage.

func SyncChangedCaller added in v0.6.0

func SyncChangedCaller(handler interface{}, params ...interface{})

SyncChangedCaller is the caller function for sync changed event.

func UnregisterMessageIDAliases added in v0.5.7

func UnregisterMessageIDAliases()

UnregisterMessageIDAliases removes all aliases registered through the RegisterMessageIDAlias function.

Types

type ApprovalWeightManager added in v0.5.7

type ApprovalWeightManager struct {
	Events *ApprovalWeightManagerEvents
	// contains filtered or unexported fields
}

ApprovalWeightManager is a Tangle component to keep track of relative weights of branches and markers so that consensus can be based on the heaviest perception on the tangle as a data structure.

func NewApprovalWeightManager added in v0.5.7

func NewApprovalWeightManager(tangle *Tangle) (approvalWeightManager *ApprovalWeightManager)

NewApprovalWeightManager is the constructor for ApprovalWeightManager.

func (*ApprovalWeightManager) ProcessMessage added in v0.5.7

func (a *ApprovalWeightManager) ProcessMessage(messageID MessageID)

ProcessMessage is the main entry point for the ApprovalWeightManager. It takes the Message's issuer, adds it to the supporters of the Message's ledgerstate.Branch and approved markers.Marker and eventually triggers events when approval weights for branch and markers are reached.

func (*ApprovalWeightManager) Setup added in v0.5.7

func (a *ApprovalWeightManager) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*ApprovalWeightManager) Shutdown added in v0.5.7

func (a *ApprovalWeightManager) Shutdown()

Shutdown shuts down the ApprovalWeightManager and persists its state.

func (*ApprovalWeightManager) WeightOfBranch added in v0.5.7

func (a *ApprovalWeightManager) WeightOfBranch(branchID ledgerstate.BranchID) (weight float64)

WeightOfBranch returns the weight of the given Branch that was added by Supporters of the given epoch.

func (*ApprovalWeightManager) WeightOfMarker added in v0.5.7

func (a *ApprovalWeightManager) WeightOfMarker(marker *markers.Marker, anchorTime time.Time) (weight float64)

WeightOfMarker returns the weight of the given marker based on the anchorTime.

type ApprovalWeightManagerEvents added in v0.5.7

type ApprovalWeightManagerEvents struct {
	MessageProcessed   *events.Event
	MessageFinalized   *events.Event
	BranchConfirmation *events.ThresholdEvent
	MarkerConfirmation *events.ThresholdEvent
}

ApprovalWeightManagerEvents represents events happening in the ApprovalWeightManager.

type Approver

type Approver struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Approver is an approver of a given referenced message.

func ApproverFromBytes

func ApproverFromBytes(bytes []byte) (result *Approver, consumedBytes int, err error)

ApproverFromBytes parses the given bytes into an approver.

func ApproverFromMarshalUtil

func ApproverFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result *Approver, err error)

ApproverFromMarshalUtil parses a new approver from the given marshal util.

func NewApprover

func NewApprover(approverType ApproverType, referencedMessageID MessageID, approverMessageID MessageID) *Approver

NewApprover creates a new approver relation to the given approved/referenced message.

func (*Approver) ApproverMessageID

func (a *Approver) ApproverMessageID() MessageID

ApproverMessageID returns the ID of the message which referenced the given approved message.

func (*Approver) Bytes

func (a *Approver) Bytes() []byte

Bytes returns the bytes of the approver.

func (*Approver) ObjectStorageKey

func (a *Approver) ObjectStorageKey() []byte

ObjectStorageKey marshals the keys of the stored approver into a byte array. This includes the referencedMessageID and the approverMessageID.

func (*Approver) ObjectStorageValue

func (a *Approver) ObjectStorageValue() (result []byte)

ObjectStorageValue returns the value of the stored approver object.

func (*Approver) ReferencedMessageID

func (a *Approver) ReferencedMessageID() MessageID

ReferencedMessageID returns the ID of the message which is referenced by the approver.

func (*Approver) String

func (a *Approver) String() string

String returns the string representation of the approver.

func (*Approver) Type added in v0.3.6

func (a *Approver) Type() ApproverType

Type returns the type of the Approver reference.

func (*Approver) Update

func (a *Approver) Update(other objectstorage.StorableObject)

Update updates the approver. This should should never happen and will panic if attempted.

type ApproverType added in v0.3.6

type ApproverType uint8

ApproverType is a type that represents the different kind of reverse mapping that we have for references formed by strong and weak parents.

const (
	// StrongApprover is the ApproverType that represents references formed by strong parents.
	StrongApprover ApproverType = iota

	// WeakApprover is the ApproverType that represents references formed by weak parents.
	WeakApprover
)

func ApproverTypeFromBytes added in v0.3.6

func ApproverTypeFromBytes(bytes []byte) (approverType ApproverType, consumedBytes int, err error)

ApproverTypeFromBytes unmarshals an ApproverType from a sequence of bytes.

func ApproverTypeFromMarshalUtil added in v0.3.6

func ApproverTypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (approverType ApproverType, err error)

ApproverTypeFromMarshalUtil unmarshals an ApproverType using a MarshalUtil (for easier unmarshaling).

func (ApproverType) Bytes added in v0.3.6

func (a ApproverType) Bytes() []byte

Bytes returns a marshaled version of the ApproverType.

func (ApproverType) String added in v0.3.6

func (a ApproverType) String() string

String returns a human readable version of the ApproverType.

type Attachment added in v0.3.6

type Attachment struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Attachment stores the information which transaction was attached by which message. We need this to be able to perform reverse lookups from transactions to their corresponding messages that attach them.

func AttachmentFromBytes added in v0.3.6

func AttachmentFromBytes(bytes []byte) (result *Attachment, consumedBytes int, err error)

AttachmentFromBytes unmarshals an Attachment from a sequence of bytes - it either creates a new object or fills the optionally provided one with the parsed information.

func NewAttachment added in v0.3.6

func NewAttachment(transactionID ledgerstate.TransactionID, messageID MessageID) *Attachment

NewAttachment creates an attachment object with the given information.

func ParseAttachment added in v0.3.6

func ParseAttachment(marshalUtil *marshalutil.MarshalUtil) (result *Attachment, err error)

ParseAttachment is a wrapper for simplified unmarshaling of Attachments from a byte stream using the marshalUtil package.

func (*Attachment) Bytes added in v0.3.6

func (a *Attachment) Bytes() []byte

Bytes marshals the Attachment into a sequence of bytes.

func (*Attachment) MessageID added in v0.3.6

func (a *Attachment) MessageID() MessageID

MessageID returns the messageID of this Attachment.

func (*Attachment) ObjectStorageKey added in v0.3.6

func (a *Attachment) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database.

func (*Attachment) ObjectStorageValue added in v0.3.6

func (a *Attachment) ObjectStorageValue() (data []byte)

ObjectStorageValue marshals the "content part" of an Attachment to a sequence of bytes. Since all of the information for this object are stored in its key, this method does nothing and is only required to conform with the interface.

func (*Attachment) String added in v0.3.6

func (a *Attachment) String() string

String returns a human readable version of the Attachment.

func (*Attachment) TransactionID added in v0.3.6

func (a *Attachment) TransactionID() ledgerstate.TransactionID

TransactionID returns the transactionID of this Attachment.

func (*Attachment) Update added in v0.3.6

func (a *Attachment) Update(other objectstorage.StorableObject)

Update is disabled - updates are supposed to happen through the setters (if existing).

type Booker added in v0.3.6

type Booker struct {
	// Events is a dictionary for the Booker related Events.
	Events *BookerEvents

	MarkersManager *MarkersManager
	// contains filtered or unexported fields
}

Booker is a Tangle component that takes care of booking Messages and Transactions by assigning them to the corresponding Branch of the ledger state.

func NewBooker added in v0.3.6

func NewBooker(tangle *Tangle) (messageBooker *Booker)

NewBooker is the constructor of a Booker.

func (*Booker) BookConflictingTransaction added in v0.5.7

func (b *Booker) BookConflictingTransaction(transactionID ledgerstate.TransactionID) (err error)

BookConflictingTransaction propagates new conflicts.

func (*Booker) BookMessage added in v0.5.7

func (b *Booker) BookMessage(messageID MessageID) (err error)

BookMessage tries to book the given Message (and potentially its contained Transaction) into the LedgerState and the Tangle. It fires a MessageBooked event if it succeeds.

func (*Booker) MessageBranchID added in v0.5.7

func (b *Booker) MessageBranchID(messageID MessageID) (branchID ledgerstate.BranchID, err error)

MessageBranchID returns the BranchID of the given Message.

func (*Booker) Setup added in v0.4.0

func (b *Booker) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*Booker) Shutdown added in v0.3.6

func (b *Booker) Shutdown()

Shutdown shuts down the Booker and persists its state.

type BookerEvents added in v0.3.6

type BookerEvents struct {
	// MessageBooked is triggered when a Message was booked (it's Branch and it's Payload's Branch where determined).
	MessageBooked *events.Event

	// MessageBranchUpdated is triggered when the BranchID of a Message is changed in its MessageMetadata.
	MessageBranchUpdated *events.Event

	// MarkerBranchUpdated is triggered when a Marker is mapped to a new BranchID.
	MarkerBranchUpdated *events.Event

	// Error gets triggered when the Booker faces an unexpected error.
	Error *events.Event
}

BookerEvents represents events happening in the Booker.

type BranchSupporters added in v0.5.7

type BranchSupporters struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

BranchSupporters is a data structure that tracks which nodes support a branch.

func BranchSupportersFromBytes added in v0.5.7

func BranchSupportersFromBytes(bytes []byte) (branchSupporters *BranchSupporters, consumedBytes int, err error)

BranchSupportersFromBytes unmarshals a BranchSupporters object from a sequence of bytes.

func BranchSupportersFromMarshalUtil added in v0.5.7

func BranchSupportersFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branchSupporters *BranchSupporters, err error)

BranchSupportersFromMarshalUtil unmarshals a BranchSupporters object using a MarshalUtil (for easier unmarshaling).

func NewBranchSupporters added in v0.5.7

func NewBranchSupporters(branchID ledgerstate.BranchID) (branchSupporters *BranchSupporters)

NewBranchSupporters is the constructor for the BranchSupporters object.

func (*BranchSupporters) AddSupporter added in v0.5.7

func (b *BranchSupporters) AddSupporter(supporter Supporter) (added bool)

AddSupporter adds a new Supporter to the tracked ledgerstate.BranchID.

func (*BranchSupporters) BranchID added in v0.5.7

func (b *BranchSupporters) BranchID() (branchID ledgerstate.BranchID)

BranchID returns the ledgerstate.BranchID that is being tracked.

func (*BranchSupporters) Bytes added in v0.5.7

func (b *BranchSupporters) Bytes() (marshaledBranchSupporters []byte)

Bytes returns a marshaled version of the BranchSupporters.

func (*BranchSupporters) DeleteSupporter added in v0.5.7

func (b *BranchSupporters) DeleteSupporter(supporter Supporter) (deleted bool)

DeleteSupporter deletes a Supporter from the tracked ledgerstate.BranchID.

func (*BranchSupporters) ObjectStorageKey added in v0.5.7

func (b *BranchSupporters) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*BranchSupporters) ObjectStorageValue added in v0.5.7

func (b *BranchSupporters) ObjectStorageValue() []byte

ObjectStorageValue marshals the BranchSupporters into a sequence of bytes that are used as the value part in the object storage.

func (*BranchSupporters) String added in v0.5.7

func (b *BranchSupporters) String() string

String returns a human readable version of the BranchSupporters.

func (*BranchSupporters) Supporters added in v0.5.7

func (b *BranchSupporters) Supporters() (supporters *Supporters)

Supporters returns the set of Supporters that are supporting the given ledgerstate.BranchID.

func (*BranchSupporters) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type BranchWeight added in v0.5.7

type BranchWeight struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

BranchWeight is a data structure that tracks the weight of a ledgerstate.BranchID.

func BranchWeightFromBytes added in v0.5.7

func BranchWeightFromBytes(bytes []byte) (branchWeight *BranchWeight, consumedBytes int, err error)

BranchWeightFromBytes unmarshals a BranchWeight object from a sequence of bytes.

func BranchWeightFromMarshalUtil added in v0.5.7

func BranchWeightFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (branchWeight *BranchWeight, err error)

BranchWeightFromMarshalUtil unmarshals a BranchWeight object using a MarshalUtil (for easier unmarshaling).

func NewBranchWeight added in v0.5.7

func NewBranchWeight(branchID ledgerstate.BranchID) (branchWeight *BranchWeight)

NewBranchWeight creates a new BranchWeight.

func (*BranchWeight) BranchID added in v0.5.7

func (b *BranchWeight) BranchID() (branchID ledgerstate.BranchID)

BranchID returns the ledgerstate.BranchID that is being tracked.

func (*BranchWeight) Bytes added in v0.5.7

func (b *BranchWeight) Bytes() (marshaledBranchWeight []byte)

Bytes returns a marshaled version of the BranchWeight.

func (*BranchWeight) DecreaseWeight added in v0.5.7

func (b *BranchWeight) DecreaseWeight(weight float64) (newWeight float64)

DecreaseWeight decreases the weight for the ledgerstate.BranchID and returns true if it was modified.

func (*BranchWeight) IncreaseWeight added in v0.5.7

func (b *BranchWeight) IncreaseWeight(weight float64) (newWeight float64)

IncreaseWeight increases the weight for the ledgerstate.BranchID and returns the new weight.

func (*BranchWeight) ObjectStorageKey added in v0.5.7

func (b *BranchWeight) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*BranchWeight) ObjectStorageValue added in v0.5.7

func (b *BranchWeight) ObjectStorageValue() []byte

ObjectStorageValue marshals the BranchWeight into a sequence of bytes that are used as the value part in the object storage.

func (*BranchWeight) SetWeight added in v0.5.7

func (b *BranchWeight) SetWeight(weight float64) (modified bool)

SetWeight sets the weight for the ledgerstate.BranchID and returns true if it was modified.

func (*BranchWeight) String added in v0.5.7

func (b *BranchWeight) String() string

String returns a human readable version of the BranchWeight.

func (*BranchWeight) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*BranchWeight) Weight added in v0.5.7

func (b *BranchWeight) Weight() (weight float64)

Weight returns the weight of the ledgerstate.BranchID.

type BytesFilter

type BytesFilter interface {
	// Filter filters up on the given bytes and peer and calls the acceptance callback
	// if the input passes or the rejection callback if the input is rejected.
	Filter(bytes []byte, peer *peer.Peer)
	// OnAccept registers the given callback as the acceptance function of the filter.
	OnAccept(callback func(bytes []byte, peer *peer.Peer))
	// OnReject registers the given callback as the rejection function of the filter.
	OnReject(callback func(bytes []byte, err error, peer *peer.Peer))
}

BytesFilter filters based on byte slices and peers.

type BytesRejectedEvent

type BytesRejectedEvent struct {
	Bytes []byte
	Peer  *peer.Peer
}

BytesRejectedEvent holds the information provided by the BytesRejected event that gets triggered when the bytes of a Message did not pass the parsing step.

type CManaWeightProvider added in v0.5.8

type CManaWeightProvider struct {
	// contains filtered or unexported fields
}

CManaWeightProvider is a WeightProvider for consensus mana. It keeps track of active nodes based on their time-based activity in relation to activeTimeThreshold.

func NewCManaWeightProvider added in v0.5.8

func NewCManaWeightProvider(manaRetrieverFunc ManaRetrieverFunc, timeRetrieverFunc TimeRetrieverFunc, store ...kvstore.KVStore) (cManaWeightProvider *CManaWeightProvider)

NewCManaWeightProvider is the constructor for CManaWeightProvider.

func (*CManaWeightProvider) ActiveNodes added in v0.5.8

func (c *CManaWeightProvider) ActiveNodes() (activeNodes map[identity.ID]time.Time)

ActiveNodes returns the map of the active nodes.

func (*CManaWeightProvider) Shutdown added in v0.5.8

func (c *CManaWeightProvider) Shutdown()

Shutdown shuts down the WeightProvider and persists its state.

func (*CManaWeightProvider) Update added in v0.5.8

func (c *CManaWeightProvider) Update(t time.Time, nodeID identity.ID)

Update updates the underlying data structure and keeps track of active nodes.

func (*CManaWeightProvider) Weight added in v0.5.8

func (c *CManaWeightProvider) Weight(message *Message) (weight, totalWeight float64)

Weight returns the weight and total weight for the given message.

func (*CManaWeightProvider) WeightsOfRelevantSupporters added in v0.5.8

func (c *CManaWeightProvider) WeightsOfRelevantSupporters() (weights map[identity.ID]float64, totalWeight float64)

WeightsOfRelevantSupporters returns all relevant weights.

type CachedApprover

type CachedApprover struct {
	objectstorage.CachedObject
}

CachedApprover is a wrapper for a stored cached object representing an approver.

func (*CachedApprover) Consume

func (c *CachedApprover) Consume(consumer func(approver *Approver), forceRelease ...bool) (consumed bool)

Consume consumes the cachedApprover. It releases the object when the callback is done. It returns true if the callback was called.

func (*CachedApprover) Unwrap

func (c *CachedApprover) Unwrap() *Approver

Unwrap unwraps the cached approver into the underlying approver. If stored object cannot be cast into an approver or has been deleted, it returns nil.

type CachedApprovers

type CachedApprovers []*CachedApprover

CachedApprovers defines a slice of *CachedApprover.

func (CachedApprovers) Consume

func (c CachedApprovers) Consume(consumer func(approver *Approver), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedApprovers) Release added in v0.3.6

func (c CachedApprovers) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedApprovers) String added in v0.3.6

func (c CachedApprovers) String() string

String returns a human readable version of the CachedApprovers.

func (CachedApprovers) Unwrap added in v0.3.6

func (c CachedApprovers) Unwrap() (unwrappedApprovers []*Approver)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedAttachment added in v0.3.6

type CachedAttachment struct {
	objectstorage.CachedObject
}

CachedAttachment is a wrapper for the generic CachedObject returned by the objectstorage, that overrides the accessor methods, with a type-casted one.

func (*CachedAttachment) Consume added in v0.3.6

func (cachedAttachment *CachedAttachment) Consume(consumer func(attachment *Attachment)) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedAttachment) Retain added in v0.3.6

func (cachedAttachment *CachedAttachment) Retain() *CachedAttachment

Retain marks this CachedObject to still be in use by the program.

func (*CachedAttachment) Unwrap added in v0.3.6

func (cachedAttachment *CachedAttachment) Unwrap() *Attachment

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedAttachments added in v0.3.6

type CachedAttachments []*CachedAttachment

CachedAttachments represents a collection of CachedAttachments.

func (CachedAttachments) Consume added in v0.3.6

func (cachedAttachments CachedAttachments) Consume(consumer func(attachment *Attachment)) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

type CachedBranchSupporters added in v0.5.7

type CachedBranchSupporters struct {
	objectstorage.CachedObject
}

CachedBranchSupporters is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedBranchSupporters) Consume added in v0.5.7

func (c *CachedBranchSupporters) Consume(consumer func(branchSupporters *BranchSupporters), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedBranchSupporters) Retain added in v0.5.7

Retain marks the CachedObject to still be in use by the program.

func (*CachedBranchSupporters) String added in v0.5.7

func (c *CachedBranchSupporters) String() string

String returns a human readable version of the CachedBranchSupporters.

func (*CachedBranchSupporters) Unwrap added in v0.5.7

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedBranchWeight added in v0.5.7

type CachedBranchWeight struct {
	objectstorage.CachedObject
}

CachedBranchWeight is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedBranchWeight) Consume added in v0.5.7

func (c *CachedBranchWeight) Consume(consumer func(branchWeight *BranchWeight), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedBranchWeight) Retain added in v0.5.7

Retain marks the CachedObject to still be in use by the program.

func (*CachedBranchWeight) String added in v0.5.7

func (c *CachedBranchWeight) String() string

String returns a human readable version of the CachedBranchWeight.

func (*CachedBranchWeight) Unwrap added in v0.5.7

func (c *CachedBranchWeight) Unwrap() *BranchWeight

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedIndividuallyMappedMessage added in v0.5.7

type CachedIndividuallyMappedMessage struct {
	objectstorage.CachedObject
}

CachedIndividuallyMappedMessage is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedIndividuallyMappedMessage) Consume added in v0.5.7

func (c *CachedIndividuallyMappedMessage) Consume(consumer func(individuallyMappedMessage *IndividuallyMappedMessage), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedIndividuallyMappedMessage) Retain added in v0.5.7

Retain marks the CachedObject to still be in use by the program.

func (*CachedIndividuallyMappedMessage) String added in v0.5.7

String returns a human readable version of the CachedIndividuallyMappedMessage.

func (*CachedIndividuallyMappedMessage) Unwrap added in v0.5.7

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedIndividuallyMappedMessages added in v0.5.7

type CachedIndividuallyMappedMessages []*CachedIndividuallyMappedMessage

CachedIndividuallyMappedMessages defines a slice of *CachedIndividuallyMappedMessage.

func (CachedIndividuallyMappedMessages) Consume added in v0.5.7

func (c CachedIndividuallyMappedMessages) Consume(consumer func(individuallyMappedMessage *IndividuallyMappedMessage), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedIndividuallyMappedMessages) Release added in v0.5.7

func (c CachedIndividuallyMappedMessages) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedIndividuallyMappedMessages) String added in v0.5.7

String returns a human readable version of the CachedIndividuallyMappedMessages.

func (CachedIndividuallyMappedMessages) Unwrap added in v0.5.7

func (c CachedIndividuallyMappedMessages) Unwrap() (unwrappedIndividuallyMappedMessages []*IndividuallyMappedMessage)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedMarkerIndexBranchIDMapping added in v0.3.6

type CachedMarkerIndexBranchIDMapping struct {
	objectstorage.CachedObject
}

CachedMarkerIndexBranchIDMapping is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedMarkerIndexBranchIDMapping) Consume added in v0.3.6

func (c *CachedMarkerIndexBranchIDMapping) Consume(consumer func(markerIndexBranchIDMapping *MarkerIndexBranchIDMapping), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedMarkerIndexBranchIDMapping) Retain added in v0.3.6

Retain marks the CachedObject to still be in use by the program.

func (*CachedMarkerIndexBranchIDMapping) String added in v0.3.6

String returns a human readable version of the CachedMarkerIndexBranchIDMapping.

func (*CachedMarkerIndexBranchIDMapping) Unwrap added in v0.3.6

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedMarkerMessageMapping added in v0.5.7

type CachedMarkerMessageMapping struct {
	objectstorage.CachedObject
}

CachedMarkerMessageMapping is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedMarkerMessageMapping) Consume added in v0.5.7

func (c *CachedMarkerMessageMapping) Consume(consumer func(markerMessageMapping *MarkerMessageMapping), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedMarkerMessageMapping) Retain added in v0.5.7

Retain marks the CachedObject to still be in use by the program.

func (*CachedMarkerMessageMapping) String added in v0.5.7

func (c *CachedMarkerMessageMapping) String() string

String returns a human readable version of the CachedMarkerMessageMapping.

func (*CachedMarkerMessageMapping) Unwrap added in v0.5.7

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedMarkerMessageMappings added in v0.5.7

type CachedMarkerMessageMappings []*CachedMarkerMessageMapping

CachedMarkerMessageMappings defines a slice of *CachedMarkerMessageMapping.

func (CachedMarkerMessageMappings) Consume added in v0.5.7

func (c CachedMarkerMessageMappings) Consume(consumer func(markerMessageMapping *MarkerMessageMapping), forceRelease ...bool) (consumed bool)

Consume iterates over the CachedObjects, unwraps them and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes. It returns true, if at least one object was consumed.

func (CachedMarkerMessageMappings) Release added in v0.5.7

func (c CachedMarkerMessageMappings) Release(force ...bool)

Release is a utility function that allows us to release all CachedObjects in the collection.

func (CachedMarkerMessageMappings) String added in v0.5.7

String returns a human readable version of the CachedMarkerMessageMappings.

func (CachedMarkerMessageMappings) Unwrap added in v0.5.7

func (c CachedMarkerMessageMappings) Unwrap() (unwrappedMarkerMessageMappings []*MarkerMessageMapping)

Unwrap is the type-casted equivalent of Get. It returns a slice of unwrapped objects with the object being nil if it does not exist.

type CachedMessage

type CachedMessage struct {
	objectstorage.CachedObject
}

CachedMessage defines a cached message. A wrapper for a cached object.

func (*CachedMessage) Consume

func (c *CachedMessage) Consume(consumer func(message *Message)) bool

Consume consumes the cached object and releases it when the callback is done. It returns true if the callback was called.

func (*CachedMessage) Retain

func (c *CachedMessage) Retain() *CachedMessage

Retain registers a new consumer for the cached message.

func (*CachedMessage) Unwrap

func (c *CachedMessage) Unwrap() *Message

Unwrap returns the message wrapped by the cached message. If the wrapped object cannot be cast to a Message or has been deleted, it returns nil.

type CachedMessageMetadata

type CachedMessageMetadata struct {
	objectstorage.CachedObject
}

CachedMessageMetadata is a wrapper for stored cached object that represents a message metadata.

func (*CachedMessageMetadata) Consume added in v0.3.6

func (c *CachedMessageMetadata) Consume(consumer func(messageMetadata *MessageMetadata), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedMessageMetadata) ID added in v0.3.6

func (c *CachedMessageMetadata) ID() (messageID MessageID)

ID returns the MessageID of the CachedMessageMetadata.

func (*CachedMessageMetadata) Retain

Retain registers a new consumer for the cached message metadata.

func (*CachedMessageMetadata) Unwrap

Unwrap returns the underlying stored message metadata wrapped by the CachedMessageMetadata. If the stored object cannot be cast to MessageMetadata or is deleted, it returns nil.

type CachedMissingMessage added in v0.3.6

type CachedMissingMessage struct {
	objectstorage.CachedObject
}

CachedMissingMessage is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedMissingMessage) Consume added in v0.3.6

func (c *CachedMissingMessage) Consume(consumer func(missingMessage *MissingMessage), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedMissingMessage) ID added in v0.3.6

func (c *CachedMissingMessage) ID() (id MessageID)

ID returns the MissingMessageID of the requested MissingMessage.

func (*CachedMissingMessage) Retain added in v0.3.6

Retain marks the CachedObject to still be in use by the program.

func (*CachedMissingMessage) String added in v0.3.6

func (c *CachedMissingMessage) String() string

String returns a human readable version of the CachedMissingMessage.

func (*CachedMissingMessage) Unwrap added in v0.3.6

func (c *CachedMissingMessage) Unwrap() *MissingMessage

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedSequenceSupporters added in v0.5.7

type CachedSequenceSupporters struct {
	objectstorage.CachedObject
}

CachedSequenceSupporters is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedSequenceSupporters) Consume added in v0.5.7

func (c *CachedSequenceSupporters) Consume(consumer func(sequenceSupporters *SequenceSupporters), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedSequenceSupporters) Retain added in v0.5.7

Retain marks the CachedObject to still be in use by the program.

func (*CachedSequenceSupporters) String added in v0.5.7

func (c *CachedSequenceSupporters) String() string

String returns a human readable version of the CachedSequenceSupporters.

func (*CachedSequenceSupporters) Unwrap added in v0.5.7

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type CachedStatement added in v0.5.7

type CachedStatement struct {
	objectstorage.CachedObject
}

CachedStatement is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.

func (*CachedStatement) Consume added in v0.5.7

func (c *CachedStatement) Consume(consumer func(statement *Statement), forceRelease ...bool) (consumed bool)

Consume unwraps the CachedObject and passes a type-casted version to the consumer (if the object is not empty - it exists). It automatically releases the object when the consumer finishes.

func (*CachedStatement) Retain added in v0.5.7

func (c *CachedStatement) Retain() *CachedStatement

Retain marks the CachedObject to still be in use by the program.

func (*CachedStatement) String added in v0.5.7

func (c *CachedStatement) String() string

String returns a human readable version of the CachedStatement.

func (*CachedStatement) Unwrap added in v0.5.7

func (c *CachedStatement) Unwrap() *Statement

Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.

type ConsensusManager added in v0.5.0

type ConsensusManager struct {
	Events *ConsensusManagerEvents
	// contains filtered or unexported fields
}

ConsensusManager is the component in charge of forming opinions about timestamps and payloads.

func NewConsensusManager added in v0.5.0

func NewConsensusManager(tangle *Tangle) (opinionFormer *ConsensusManager)

NewConsensusManager returns a new ConsensusManager.

func (*ConsensusManager) MessageEligible added in v0.5.0

func (o *ConsensusManager) MessageEligible(messageID MessageID) (eligible bool)

MessageEligible returns whether the given messageID is marked as eligible.

func (*ConsensusManager) PayloadLiked added in v0.5.0

func (o *ConsensusManager) PayloadLiked(messageID MessageID) (liked bool)

PayloadLiked returns the opinion of the given MessageID.

func (*ConsensusManager) SetTransactionLiked added in v0.5.8

func (o *ConsensusManager) SetTransactionLiked(transactionID ledgerstate.TransactionID, liked bool) (modified bool)

SetTransactionLiked sets the transaction like status.

func (*ConsensusManager) Setup added in v0.5.0

func (o *ConsensusManager) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of the other components.

func (*ConsensusManager) Shutdown added in v0.5.0

func (o *ConsensusManager) Shutdown()

Shutdown shuts down the component and persists its state.

type ConsensusManagerEvents added in v0.5.0

type ConsensusManagerEvents struct {
	// Fired when an opinion of a message is formed.
	MessageOpinionFormed *events.Event
	// Fired when after a received statement is processed.
	StatementProcessed *events.Event
}

ConsensusManagerEvents defines all the events related to the opinion manager.

type ConsensusMechanism added in v0.5.0

type ConsensusMechanism interface {
	// Init initializes the ConsensusMechanism by making the Tangle object available that is using it.
	Init(tangle *Tangle)

	// Setup sets up the behavior of the ConsensusMechanism by making it attach to the relevant events in the Tangle.
	Setup()

	// TransactionLiked returns a boolean value indicating whether the given Transaction is liked.
	TransactionLiked(transactionID ledgerstate.TransactionID) (liked bool)

	// Shutdown shuts down the ConsensusMechanism and persists its state.
	Shutdown()

	// SetTransactionLiked sets the transaction like status.
	SetTransactionLiked(transactionID ledgerstate.TransactionID, liked bool) (modified bool)
}

ConsensusMechanism is a generic interface allowing the Tangle to use different methods to reach consensus.

type Events

type Events struct {
	// MessageInvalid is triggered when a Message is detected to be objectively invalid.
	MessageInvalid *events.Event

	// Fired when a message has been eligible.
	MessageEligible *events.Event

	// Error is triggered when the Tangle faces an error from which it can not recover.
	Error *events.Event
}

Events represents events happening in the Tangle.

type IndividuallyMappedMessage added in v0.5.7

type IndividuallyMappedMessage struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

IndividuallyMappedMessage is a data structure that denotes if a Message has its BranchID set individually in its own MessageMetadata.

func IndividuallyMappedMessageFromBytes added in v0.5.7

func IndividuallyMappedMessageFromBytes(bytes []byte) (individuallyMappedMessage *IndividuallyMappedMessage, consumedBytes int, err error)

IndividuallyMappedMessageFromBytes unmarshals an IndividuallyMappedMessage from a sequence of bytes.

func IndividuallyMappedMessageFromMarshalUtil added in v0.5.7

func IndividuallyMappedMessageFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (individuallyMappedMessage *IndividuallyMappedMessage, err error)

IndividuallyMappedMessageFromMarshalUtil unmarshals an IndividuallyMappedMessage using a MarshalUtil (for easier unmarshaling).

func NewIndividuallyMappedMessage added in v0.5.7

func NewIndividuallyMappedMessage(branchID ledgerstate.BranchID, messageID MessageID, pastMarkers *markers.Markers) *IndividuallyMappedMessage

NewIndividuallyMappedMessage is the constructor for the IndividuallyMappedMessage.

func (*IndividuallyMappedMessage) BranchID added in v0.5.7

BranchID returns the BranchID that the Message that has its Branch mapped in its MessageMetadata is currently booked into.

func (*IndividuallyMappedMessage) Bytes added in v0.5.7

func (i *IndividuallyMappedMessage) Bytes() []byte

Bytes returns a marshaled version of the IndividuallyMappedMessage.

func (*IndividuallyMappedMessage) MessageID added in v0.5.7

func (i *IndividuallyMappedMessage) MessageID() MessageID

MessageID returns the MessageID of the Message that has its Branch mapped in its MessageMetadata.

func (*IndividuallyMappedMessage) ObjectStorageKey added in v0.5.7

func (i *IndividuallyMappedMessage) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*IndividuallyMappedMessage) ObjectStorageValue added in v0.5.7

func (i *IndividuallyMappedMessage) ObjectStorageValue() []byte

ObjectStorageValue marshals the IndividuallyMappedMessage into a sequence of bytes that are used as the value part in the object storage.

func (*IndividuallyMappedMessage) PastMarkers added in v0.5.7

func (i *IndividuallyMappedMessage) PastMarkers() *markers.Markers

PastMarkers returns the PastMarkers of the Message that has its Branch mapped in its MessageMetadata.

func (*IndividuallyMappedMessage) String added in v0.5.7

func (i *IndividuallyMappedMessage) String() string

String returns a human readable version of the IndividuallyMappedMessage.

func (*IndividuallyMappedMessage) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type LastConfirmedMessage added in v0.5.8

type LastConfirmedMessage struct {
	MessageID MessageID
	Time      time.Time
}

LastConfirmedMessage is a wrapper type for the last confirmed message, consisting of MessageID and time.

func (LastConfirmedMessage) Bytes added in v0.5.8

func (l LastConfirmedMessage) Bytes() (marshaledLastConfirmedMessage []byte)

Bytes returns a marshaled version of the LastConfirmedMessage.

func (LastConfirmedMessage) String added in v0.5.8

func (l LastConfirmedMessage) String() string

String returns a human readable version of the LastConfirmedMessage.

type LedgerState added in v0.3.6

type LedgerState struct {
	BranchDAG *ledgerstate.BranchDAG
	UTXODAG   ledgerstate.IUTXODAG
	// contains filtered or unexported fields
}

LedgerState is a Tangle component that wraps the components of the ledgerstate package and makes them available at a "single point of contact".

func NewLedgerState added in v0.3.6

func NewLedgerState(tangle *Tangle) (ledgerState *LedgerState)

NewLedgerState is the constructor of the LedgerState component.

func (*LedgerState) BookTransaction added in v0.3.6

func (l *LedgerState) BookTransaction(transaction *ledgerstate.Transaction, messageID MessageID) (targetBranch ledgerstate.BranchID, err error)

BookTransaction books the given Transaction into the underlying LedgerState and returns the target Branch and an eventual error.

func (*LedgerState) BranchID added in v0.3.6

func (l *LedgerState) BranchID(transactionID ledgerstate.TransactionID) (branchID ledgerstate.BranchID)

BranchID returns the branchID of the given transactionID.

func (*LedgerState) BranchInclusionState added in v0.3.6

func (l *LedgerState) BranchInclusionState(branchID ledgerstate.BranchID) (inclusionState ledgerstate.InclusionState)

BranchInclusionState returns the InclusionState of the Branch with the given BranchID which can either be Pending, Confirmed or Rejected.

func (*LedgerState) CachedOutput added in v0.6.2

func (l *LedgerState) CachedOutput(outputID ledgerstate.OutputID) *ledgerstate.CachedOutput

CachedOutput returns the Output with the given ID.

func (*LedgerState) CachedOutputMetadata added in v0.6.2

func (l *LedgerState) CachedOutputMetadata(outputID ledgerstate.OutputID) *ledgerstate.CachedOutputMetadata

CachedOutputMetadata returns the OutputMetadata with the given ID.

func (*LedgerState) CachedOutputsOnAddress added in v0.6.2

func (l *LedgerState) CachedOutputsOnAddress(address ledgerstate.Address) (cachedOutputs ledgerstate.CachedOutputs)

CachedOutputsOnAddress retrieves all the Outputs that are associated with an address.

func (*LedgerState) CheckTransaction added in v0.4.0

func (l *LedgerState) CheckTransaction(transaction *ledgerstate.Transaction) (err error)

CheckTransaction contains fast checks that have to be performed before booking a Transaction.

func (*LedgerState) ConflictSet added in v0.3.6

func (l *LedgerState) ConflictSet(transactionID ledgerstate.TransactionID) (conflictSet ledgerstate.TransactionIDs)

ConflictSet returns the list of transactionIDs conflicting with the given transactionID.

func (*LedgerState) ConsumedOutputs added in v0.4.1

func (l *LedgerState) ConsumedOutputs(transaction *ledgerstate.Transaction) (cachedInputs ledgerstate.CachedOutputs)

ConsumedOutputs returns the consumed (cached)Outputs of the given Transaction.

func (*LedgerState) Consumers added in v0.5.3

func (l *LedgerState) Consumers(outputID ledgerstate.OutputID) (cachedTransactions ledgerstate.CachedConsumers)

Consumers returns the (cached) consumers of the given outputID.

func (*LedgerState) InheritBranch added in v0.3.6

func (l *LedgerState) InheritBranch(referencedBranchIDs ledgerstate.BranchIDs) (inheritedBranch ledgerstate.BranchID, err error)

InheritBranch implements the inheritance rules for Branches in the Tangle. It returns a single inherited Branch and automatically creates an AggregatedBranch if necessary.

func (*LedgerState) LoadSnapshot added in v0.3.6

func (l *LedgerState) LoadSnapshot(snapshot *ledgerstate.Snapshot) (err error)

LoadSnapshot creates a set of outputs in the UTXO-DAG, that are forming the genesis for future transactions.

func (*LedgerState) ReturnTransaction added in v0.6.2

func (l *LedgerState) ReturnTransaction(transactionID ledgerstate.TransactionID) (transaction *ledgerstate.Transaction)

ReturnTransaction returns a specific transaction.

func (*LedgerState) Shutdown added in v0.3.6

func (l *LedgerState) Shutdown()

Shutdown shuts down the LedgerState and persists its state.

func (*LedgerState) SnapshotUTXO added in v0.6.2

func (l *LedgerState) SnapshotUTXO() (snapshot *ledgerstate.Snapshot)

SnapshotUTXO returns the UTXO snapshot, which is a list of transactions with unspent outputs.

func (*LedgerState) TotalSupply added in v0.6.0

func (l *LedgerState) TotalSupply() (totalSupply uint64)

TotalSupply returns the total supply.

func (*LedgerState) Transaction added in v0.4.0

func (l *LedgerState) Transaction(transactionID ledgerstate.TransactionID) *ledgerstate.CachedTransaction

Transaction retrieves the Transaction with the given TransactionID from the object storage.

func (*LedgerState) TransactionConflicting added in v0.3.6

func (l *LedgerState) TransactionConflicting(transactionID ledgerstate.TransactionID) bool

TransactionConflicting returns whether the given transaction is part of a conflict.

func (*LedgerState) TransactionInclusionState added in v0.3.6

func (l *LedgerState) TransactionInclusionState(transactionID ledgerstate.TransactionID) (ledgerstate.InclusionState, error)

TransactionInclusionState returns the InclusionState of the Transaction with the given TransactionID which can either be Pending, Confirmed or Rejected.

func (*LedgerState) TransactionMetadata added in v0.3.6

func (l *LedgerState) TransactionMetadata(transactionID ledgerstate.TransactionID) (cachedTransactionMetadata *ledgerstate.CachedTransactionMetadata)

TransactionMetadata retrieves the TransactionMetadata with the given TransactionID from the object storage.

func (*LedgerState) TransactionValid added in v0.3.6

func (l *LedgerState) TransactionValid(transaction *ledgerstate.Transaction, messageID MessageID) (err error)

TransactionValid performs some fast checks of the Transaction and triggers a MessageInvalid event if the checks do not pass.

func (*LedgerState) Transactions added in v0.6.2

func (l *LedgerState) Transactions() (transactions map[ledgerstate.TransactionID]*ledgerstate.Transaction)

Transactions returns all the transactions.

type ManaRetrieverFunc added in v0.5.8

type ManaRetrieverFunc func() map[identity.ID]float64

ManaRetrieverFunc is a function type to retrieve consensus mana (e.g. via the mana plugin)

type MarkerIndexBranchIDMapping added in v0.3.6

type MarkerIndexBranchIDMapping struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

MarkerIndexBranchIDMapping is a data structure that allows to map marker Indexes to a BranchID.

func MarkerIndexBranchIDMappingFromBytes added in v0.3.6

func MarkerIndexBranchIDMappingFromBytes(bytes []byte) (markerIndexBranchIDMapping *MarkerIndexBranchIDMapping, consumedBytes int, err error)

MarkerIndexBranchIDMappingFromBytes unmarshals a MarkerIndexBranchIDMapping from a sequence of bytes.

func MarkerIndexBranchIDMappingFromMarshalUtil added in v0.3.6

func MarkerIndexBranchIDMappingFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (markerIndexBranchIDMapping *MarkerIndexBranchIDMapping, err error)

MarkerIndexBranchIDMappingFromMarshalUtil unmarshals a MarkerIndexBranchIDMapping using a MarshalUtil (for easier unmarshaling).

func NewMarkerIndexBranchIDMapping added in v0.3.6

func NewMarkerIndexBranchIDMapping(sequenceID markers.SequenceID) (markerBranchMapping *MarkerIndexBranchIDMapping)

NewMarkerIndexBranchIDMapping creates a new MarkerIndexBranchIDMapping for the given SequenceID.

func (*MarkerIndexBranchIDMapping) BranchID added in v0.3.6

func (m *MarkerIndexBranchIDMapping) BranchID(markerIndex markers.Index) (branchID ledgerstate.BranchID)

BranchID returns the BranchID that is associated to the given marker Index.

func (*MarkerIndexBranchIDMapping) Bytes added in v0.3.6

func (m *MarkerIndexBranchIDMapping) Bytes() []byte

Bytes returns a marshaled version of the MarkerIndexBranchIDMapping.

func (*MarkerIndexBranchIDMapping) Ceiling added in v0.5.7

func (m *MarkerIndexBranchIDMapping) Ceiling(index markers.Index) (marker markers.Index, branchID ledgerstate.BranchID, exists bool)

Ceiling returns the smallest Index that is >= the given Index which has a mapped BranchID (and a boolean value indicating if it exists).

func (*MarkerIndexBranchIDMapping) Floor added in v0.5.7

func (m *MarkerIndexBranchIDMapping) Floor(index markers.Index) (marker markers.Index, branchID ledgerstate.BranchID, exists bool)

Floor returns the largest Index that is <= the given Index which has a mapped BranchID (and a boolean value indicating if it exists).

func (*MarkerIndexBranchIDMapping) ObjectStorageKey added in v0.3.6

func (m *MarkerIndexBranchIDMapping) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*MarkerIndexBranchIDMapping) ObjectStorageValue added in v0.3.6

func (m *MarkerIndexBranchIDMapping) ObjectStorageValue() []byte

ObjectStorageValue marshals the ConflictBranch into a sequence of bytes that are used as the value part in the object storage.

func (*MarkerIndexBranchIDMapping) SequenceID added in v0.3.6

SequenceID returns the SequenceID that this MarkerIndexBranchIDMapping represents.

func (*MarkerIndexBranchIDMapping) SetBranchID added in v0.3.6

func (m *MarkerIndexBranchIDMapping) SetBranchID(index markers.Index, branchID ledgerstate.BranchID)

SetBranchID creates a mapping between the given marker Index and the given BranchID.

func (*MarkerIndexBranchIDMapping) String added in v0.3.6

func (m *MarkerIndexBranchIDMapping) String() string

String returns a human readable version of the MarkerIndexBranchIDMapping.

func (*MarkerIndexBranchIDMapping) Update added in v0.3.6

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type MarkerMessageMapping added in v0.5.7

type MarkerMessageMapping struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

MarkerMessageMapping is a data structure that denotes a mapping from a Marker to a Message.

func MarkerMessageMappingFromBytes added in v0.5.7

func MarkerMessageMappingFromBytes(bytes []byte) (individuallyMappedMessage *MarkerMessageMapping, consumedBytes int, err error)

MarkerMessageMappingFromBytes unmarshals an MarkerMessageMapping from a sequence of bytes.

func MarkerMessageMappingFromMarshalUtil added in v0.5.7

func MarkerMessageMappingFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (markerMessageMapping *MarkerMessageMapping, err error)

MarkerMessageMappingFromMarshalUtil unmarshals an MarkerMessageMapping using a MarshalUtil (for easier unmarshaling).

func NewMarkerMessageMapping added in v0.5.7

func NewMarkerMessageMapping(marker *markers.Marker, messageID MessageID) *MarkerMessageMapping

NewMarkerMessageMapping is the constructor for the MarkerMessageMapping.

func (*MarkerMessageMapping) Bytes added in v0.5.7

func (m *MarkerMessageMapping) Bytes() []byte

Bytes returns a marshaled version of the MarkerMessageMapping.

func (*MarkerMessageMapping) Marker added in v0.5.7

func (m *MarkerMessageMapping) Marker() *markers.Marker

Marker returns the Marker that is mapped to a MessageID.

func (*MarkerMessageMapping) MessageID added in v0.5.7

func (m *MarkerMessageMapping) MessageID() MessageID

MessageID returns the MessageID of the Marker.

func (*MarkerMessageMapping) ObjectStorageKey added in v0.5.7

func (m *MarkerMessageMapping) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*MarkerMessageMapping) ObjectStorageValue added in v0.5.7

func (m *MarkerMessageMapping) ObjectStorageValue() []byte

ObjectStorageValue marshals the MarkerMessageMapping into a sequence of bytes that are used as the value part in the object storage.

func (*MarkerMessageMapping) String added in v0.5.7

func (m *MarkerMessageMapping) String() string

String returns a human readable version of the MarkerMessageMapping.

func (*MarkerMessageMapping) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type MarkersManager added in v0.3.6

type MarkersManager struct {
	*markers.Manager
	// contains filtered or unexported fields
}

MarkersManager is a Tangle component that takes care of managing the Markers which are used to infer structural information about the Tangle in an efficient way.

func NewMarkersManager added in v0.3.6

func NewMarkersManager(tangle *Tangle) *MarkersManager

NewMarkersManager is the constructor of the MarkersManager.

func (*MarkersManager) BranchID added in v0.5.7

func (m *MarkersManager) BranchID(marker *markers.Marker) (branchID ledgerstate.BranchID)

BranchID returns the BranchID that is associated with the given Marker.

func (*MarkersManager) BranchMappedByPastMarkers added in v0.5.7

func (m *MarkersManager) BranchMappedByPastMarkers(branch ledgerstate.BranchID, pastMarkers *markers.Markers) (branchMappedByPastMarkers bool)

BranchMappedByPastMarkers returns true if the given BranchID is associated to at least one of the given past Markers.

func (*MarkersManager) Ceiling added in v0.5.7

func (m *MarkersManager) Ceiling(referenceMarker *markers.Marker) (marker markers.Index, branchID ledgerstate.BranchID, exists bool)

Ceiling returns the smallest Index that is >= the given Marker, it's BranchID and a boolean value indicating if it exists.

func (*MarkersManager) Floor added in v0.5.7

func (m *MarkersManager) Floor(referenceMarker *markers.Marker) (marker markers.Index, branchID ledgerstate.BranchID, exists bool)

Floor returns the largest Index that is <= the given Marker, it's BranchID and a boolean value indicating if it exists.

func (*MarkersManager) InheritStructureDetails added in v0.3.6

func (m *MarkersManager) InheritStructureDetails(message *Message, sequenceAlias markers.SequenceAlias) (structureDetails *markers.StructureDetails)

InheritStructureDetails returns the structure Details of a Message that are derived from the StructureDetails of its strong parents.

func (*MarkersManager) MessageID added in v0.5.7

func (m *MarkersManager) MessageID(marker *markers.Marker) (messageID MessageID)

MessageID retrieves the MessageID of the given Marker.

func (*MarkersManager) SetBranchID added in v0.5.7

func (m *MarkersManager) SetBranchID(marker *markers.Marker, branchID ledgerstate.BranchID) (updated bool)

SetBranchID associates a BranchID with the given Marker.

func (*MarkersManager) SetMessageID added in v0.5.7

func (m *MarkersManager) SetMessageID(marker *markers.Marker, messageID MessageID)

SetMessageID associates a MessageID with the given Marker.

type Message

type Message struct {
	// base functionality of StorableObject
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Message represents the core message for the base layer Tangle.

func MessageFromBytes

func MessageFromBytes(bytes []byte) (result *Message, consumedBytes int, err error)

MessageFromBytes parses the given bytes into a message.

func MessageFromMarshalUtil

func MessageFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result *Message, err error)

MessageFromMarshalUtil parses a message from the given marshal util.

func NewMessage

func NewMessage(strongParents []MessageID, weakParents []MessageID, issuingTime time.Time, issuerPublicKey ed25519.PublicKey, sequenceNumber uint64, payload payload.Payload, nonce uint64, signature ed25519.Signature) (result *Message)

NewMessage creates a new message with the details provided by the issuer.

func (*Message) Bytes

func (m *Message) Bytes() []byte

Bytes returns the message in serialized byte form.

func (*Message) ForEachParent added in v0.3.1

func (m *Message) ForEachParent(consumer func(parent Parent))

ForEachParent executes a consumer func for each parent.

func (*Message) ForEachStrongParent added in v0.3.1

func (m *Message) ForEachStrongParent(consumer func(parentMessageID MessageID))

ForEachStrongParent executes a consumer func for each strong parent.

func (*Message) ForEachWeakParent added in v0.3.1

func (m *Message) ForEachWeakParent(consumer func(parentMessageID MessageID))

ForEachWeakParent executes a consumer func for each weak parent.

func (*Message) ID

func (m *Message) ID() (result MessageID)

ID returns the id of the message which is made up of the content id and parent1/parent2 ids. This id can be used for merkle proofs.

func (*Message) IDBytes added in v0.6.2

func (m *Message) IDBytes() []byte

IDBytes implements Element interface in scheduler NodeQueue that returns the MessageID of the message in bytes.

func (*Message) IssuerPublicKey

func (m *Message) IssuerPublicKey() ed25519.PublicKey

IssuerPublicKey returns the public key of the message issuer.

func (*Message) IssuingTime

func (m *Message) IssuingTime() time.Time

IssuingTime returns the time when this message was created.

func (*Message) Nonce

func (m *Message) Nonce() uint64

Nonce returns the nonce of the message.

func (*Message) ObjectStorageKey

func (m *Message) ObjectStorageKey() []byte

ObjectStorageKey returns the key of the stored message object. This returns the bytes of the message ID.

func (*Message) ObjectStorageValue

func (m *Message) ObjectStorageValue() []byte

ObjectStorageValue returns the value stored in object storage. This returns the bytes of message.

func (*Message) Parents added in v0.3.6

func (m *Message) Parents() (parents MessageIDs)

Parents returns a slice of all parents of the Message.

func (*Message) ParentsCount added in v0.3.1

func (m *Message) ParentsCount() uint8

ParentsCount returns the total parents count of this message.

func (*Message) Payload

func (m *Message) Payload() payload.Payload

Payload returns the payload of the message.

func (*Message) SequenceNumber

func (m *Message) SequenceNumber() uint64

SequenceNumber returns the sequence number of this message.

func (*Message) Signature

func (m *Message) Signature() ed25519.Signature

Signature returns the signature of the message.

func (*Message) Size added in v0.6.2

func (m *Message) Size() int

Size returns the message size in bytes.

func (*Message) String

func (m *Message) String() string

func (*Message) StrongParents added in v0.3.1

func (m *Message) StrongParents() MessageIDs

StrongParents returns a slice of all strong parents of the message.

func (*Message) Update

Update updates the object with the values of another object. Since a Message is immutable, this function is not implemented and panics.

func (*Message) VerifySignature

func (m *Message) VerifySignature() bool

VerifySignature verifies the signature of the message.

func (*Message) Version added in v0.3.1

func (m *Message) Version() uint8

Version returns the message version.

func (*Message) WeakParents added in v0.3.1

func (m *Message) WeakParents() MessageIDs

WeakParents returns a slice of all weak parents of the message.

type MessageExistsFunc

type MessageExistsFunc func(messageId MessageID) bool

MessageExistsFunc is a function that tells if a message exists.

type MessageFactory

type MessageFactory struct {
	Events *MessageFactoryEvents
	// contains filtered or unexported fields
}

MessageFactory acts as a factory to create new messages.

func NewMessageFactory

func NewMessageFactory(tangle *Tangle, selector TipSelector) *MessageFactory

NewMessageFactory creates a new message factory.

func (*MessageFactory) IssuePayload

func (f *MessageFactory) IssuePayload(p payload.Payload, parentsCount ...int) (*Message, error)

IssuePayload creates a new message including sequence number and tip selection and returns it. It also triggers the MessageConstructed event once it's done, which is for example used by the plugins to listen for messages that shall be attached to the tangle.

func (*MessageFactory) SetTimeout added in v0.6.2

func (f *MessageFactory) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for PoW.

func (*MessageFactory) SetWorker

func (f *MessageFactory) SetWorker(worker Worker)

SetWorker sets the PoW worker to be used for the messages.

func (*MessageFactory) Shutdown

func (f *MessageFactory) Shutdown()

Shutdown closes the MessageFactory and persists the sequence number.

type MessageFactoryEvents

type MessageFactoryEvents struct {
	// Fired when a message is built including tips, sequence number and other metadata.
	MessageConstructed *events.Event

	// Fired when an error occurred.
	Error *events.Event
}

MessageFactoryEvents represents events happening on a message factory.

type MessageFilter

type MessageFilter interface {
	// Filter filters up on the given message and peer and calls the acceptance callback
	// if the input passes or the rejection callback if the input is rejected.
	Filter(msg *Message, peer *peer.Peer)
	// OnAccept registers the given callback as the acceptance function of the filter.
	OnAccept(callback func(msg *Message, peer *peer.Peer))
	// OnAccept registers the given callback as the rejection function of the filter.
	OnReject(callback func(msg *Message, err error, peer *peer.Peer))
	// Closer closes the filter.
	io.Closer
}

MessageFilter filters based on messages and peers.

type MessageID

type MessageID [MessageIDLength]byte

MessageID identifies a message via its BLAKE2b-256 hash of its bytes.

func MessageIDFromBytes

func MessageIDFromBytes(bytes []byte) (result MessageID, consumedBytes int, err error)

MessageIDFromBytes unmarshals a message id from a sequence of bytes.

func MessageIDFromMarshalUtil

func MessageIDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (MessageID, error)

MessageIDFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.

func NewMessageID

func NewMessageID(base58EncodedString string) (result MessageID, err error)

NewMessageID creates a new message id.

func (MessageID) Base58 added in v0.5.7

func (id MessageID) Base58() string

Base58 returns a base58 encoded version of the MessageID.

func (MessageID) Bytes

func (id MessageID) Bytes() []byte

Bytes returns the bytes of the MessageID.

func (*MessageID) MarshalBinary

func (id *MessageID) MarshalBinary() (result []byte, err error)

MarshalBinary marshals the MessageID into bytes.

func (MessageID) String

func (id MessageID) String() string

String returns a human readable representation of the MessageID.

func (*MessageID) UnmarshalBinary

func (id *MessageID) UnmarshalBinary(data []byte) (err error)

UnmarshalBinary unmarshals the bytes into an MessageID.

type MessageIDs added in v0.3.1

type MessageIDs []MessageID

MessageIDs is a slice of MessageID.

func (MessageIDs) ToStrings added in v0.3.1

func (ids MessageIDs) ToStrings() []string

ToStrings converts a slice of MessageIDs to a slice of strings.

type MessageInvalidEvent added in v0.7.6

type MessageInvalidEvent struct {
	MessageID MessageID
	Error     error
}

MessageInvalidEvent is struct that is passed along with triggering a messageInvalidEvent.

type MessageMetadata

type MessageMetadata struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

MessageMetadata defines the metadata for a message.

func MessageMetadataFromBytes

func MessageMetadataFromBytes(bytes []byte) (result *MessageMetadata, consumedBytes int, err error)

MessageMetadataFromBytes unmarshals the given bytes into a MessageMetadata.

func MessageMetadataFromMarshalUtil

func MessageMetadataFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result *MessageMetadata, err error)

MessageMetadataFromMarshalUtil parses a Message from the given MarshalUtil.

func NewMessageMetadata

func NewMessageMetadata(messageID MessageID) *MessageMetadata

NewMessageMetadata creates a new MessageMetadata from the specified messageID.

func (*MessageMetadata) BookedTime added in v0.5.3

func (m *MessageMetadata) BookedTime() time.Time

BookedTime returns the time when the message represented by this metadata was booked.

func (*MessageMetadata) BranchID added in v0.3.6

func (m *MessageMetadata) BranchID() ledgerstate.BranchID

BranchID returns the branch ID of the message.

func (*MessageMetadata) Bytes

func (m *MessageMetadata) Bytes() []byte

Bytes returns a marshaled version of the whole MessageMetadata object.

func (*MessageMetadata) FinalizedTime added in v0.5.8

func (m *MessageMetadata) FinalizedTime() time.Time

FinalizedTime returns the time when the message represented by this metadata was finalized.

func (*MessageMetadata) ID added in v0.3.6

func (m *MessageMetadata) ID() MessageID

ID returns the MessageID of the Message that this MessageMetadata object belongs to.

func (*MessageMetadata) IsBooked added in v0.3.6

func (m *MessageMetadata) IsBooked() (result bool)

IsBooked returns true if the message represented by this metadata is booked. False otherwise.

func (*MessageMetadata) IsEligible added in v0.3.6

func (m *MessageMetadata) IsEligible() (result bool)

IsEligible returns true if the message represented by this metadata is eligible. False otherwise.

func (*MessageMetadata) IsFinalized added in v0.5.8

func (m *MessageMetadata) IsFinalized() (result bool)

IsFinalized returns true if the message represented by this metadata is finalized by approval weight. False otherwise.

func (*MessageMetadata) IsInvalid added in v0.3.6

func (m *MessageMetadata) IsInvalid() (result bool)

IsInvalid returns true if the message represented by this metadata is invalid. False otherwise.

func (*MessageMetadata) IsSolid

func (m *MessageMetadata) IsSolid() (result bool)

IsSolid returns true if the message represented by this metadata is solid. False otherwise.

func (*MessageMetadata) ObjectStorageKey

func (m *MessageMetadata) ObjectStorageKey() []byte

ObjectStorageKey returns the key of the stored message metadata object. This returns the bytes of the messageID.

func (*MessageMetadata) ObjectStorageValue

func (m *MessageMetadata) ObjectStorageValue() []byte

ObjectStorageValue returns the value of the stored message metadata object. This includes the receivedTime, solidificationTime and solid status.

func (*MessageMetadata) ReceivedTime

func (m *MessageMetadata) ReceivedTime() time.Time

ReceivedTime returns the time when the message was received.

func (*MessageMetadata) Scheduled added in v0.4.0

func (m *MessageMetadata) Scheduled() (result bool)

Scheduled returns true if the message represented by this metadata was scheduled. False otherwise.

func (*MessageMetadata) ScheduledBypass added in v0.7.5

func (m *MessageMetadata) ScheduledBypass() (result bool)

ScheduledBypass returns true if the message represented by this metadata was scheduledBypassed. False otherwise.

func (*MessageMetadata) ScheduledTime added in v0.5.3

func (m *MessageMetadata) ScheduledTime() time.Time

ScheduledTime returns the time when the message represented by this metadata was scheduled.

func (*MessageMetadata) SetBooked added in v0.3.6

func (m *MessageMetadata) SetBooked(booked bool) (modified bool)

SetBooked sets the message associated with this metadata as booked. It returns true if the booked status is modified. False otherwise.

func (*MessageMetadata) SetBranchID added in v0.3.6

func (m *MessageMetadata) SetBranchID(bID ledgerstate.BranchID) (modified bool)

SetBranchID sets the branch ID of the message.

func (*MessageMetadata) SetEligible added in v0.3.6

func (m *MessageMetadata) SetEligible(eligible bool) (modified bool)

SetEligible sets the message associated with this metadata as eligible. It returns true if the eligible status is modified. False otherwise.

func (*MessageMetadata) SetFinalized added in v0.5.8

func (m *MessageMetadata) SetFinalized(finalized bool) (modified bool)

SetFinalized sets the message associated with this metadata as finalized by approval weight. It returns true if the finalized status is modified. False otherwise.

func (*MessageMetadata) SetInvalid added in v0.3.6

func (m *MessageMetadata) SetInvalid(invalid bool) (modified bool)

SetInvalid sets the message associated with this metadata as invalid. It returns true if the invalid status is modified. False otherwise.

func (*MessageMetadata) SetScheduled added in v0.4.0

func (m *MessageMetadata) SetScheduled(scheduled bool) (modified bool)

SetScheduled sets the message associated with this metadata as scheduled. It returns true if the scheduled status is modified. False otherwise.

func (*MessageMetadata) SetScheduledBypass added in v0.7.5

func (m *MessageMetadata) SetScheduledBypass(scheduledBypass bool) (modified bool)

SetScheduledBypass sets the message associated with this metadata as scheduledBypass. It returns true if the scheduledBypass status is modified. False otherwise.

func (*MessageMetadata) SetSolid

func (m *MessageMetadata) SetSolid(solid bool) (modified bool)

SetSolid sets the message associated with this metadata as solid. It returns true if the solid status is modified. False otherwise.

func (*MessageMetadata) SetStructureDetails added in v0.3.6

func (m *MessageMetadata) SetStructureDetails(structureDetails *markers.StructureDetails) (modified bool)

SetStructureDetails sets the structureDetails of the message.

func (*MessageMetadata) SolidificationTime

func (m *MessageMetadata) SolidificationTime() time.Time

SolidificationTime returns the time when the message was marked to be solid.

func (*MessageMetadata) String added in v0.4.0

func (m *MessageMetadata) String() string

String returns a human readable version of the MessageMetadata.

func (*MessageMetadata) StructureDetails added in v0.3.6

func (m *MessageMetadata) StructureDetails() *markers.StructureDetails

StructureDetails returns the structureDetails of the message.

func (*MessageMetadata) Update

Update updates the message metadata. This should never happen and will panic if attempted.

type MessageOption added in v0.5.3

type MessageOption func(*MessageTestFrameworkMessageOptions)

MessageOption is the type that is used for options that can be passed into the CreateMessage method to configure its behavior.

func WithColoredOutput added in v0.5.3

func WithColoredOutput(alias string, balances map[ledgerstate.Color]uint64) MessageOption

WithColoredOutput returns a MessageOption that is used to define a colored Output for the Transaction in the Message.

func WithInputs added in v0.5.3

func WithInputs(inputAliases ...string) MessageOption

WithInputs returns a MessageOption that is used to provide the Inputs of the Transaction.

func WithIssuer added in v0.5.7

func WithIssuer(issuer ed25519.PublicKey) MessageOption

WithIssuer returns a MessageOption that is used to define the issuer of the Message.

func WithOutput added in v0.5.3

func WithOutput(alias string, balance uint64) MessageOption

WithOutput returns a MessageOption that is used to define a non-colored Output for the Transaction in the Message.

func WithStrongParents added in v0.5.3

func WithStrongParents(messageAliases ...string) MessageOption

WithStrongParents returns a MessageOption that is used to define the strong parents of the Message.

func WithWeakParents added in v0.5.3

func WithWeakParents(messageAliases ...string) MessageOption

WithWeakParents returns a MessageOption that is used to define the weak parents of the Message.

type MessageParsedEvent

type MessageParsedEvent struct {
	// Message contains the parsed Message.
	Message *Message

	// Peer contains the node that sent this Message to the node.
	Peer *peer.Peer
}

MessageParsedEvent holds the information provided by the MessageParsed event that gets triggered when a message was fully parsed and syntactically validated.

type MessageRejectedEvent

type MessageRejectedEvent struct {
	Message *Message
	Peer    *peer.Peer
}

MessageRejectedEvent holds the information provided by the MessageRejected event that gets triggered when the Message was detected to be invalid.

type MessageRequesterEvents

type MessageRequesterEvents struct {
	// Fired when a request for a given message should be sent.
	SendRequest *events.Event
}

MessageRequesterEvents represents events happening on a message requester.

type MessageSignatureFilter

type MessageSignatureFilter struct {
	// contains filtered or unexported fields
}

MessageSignatureFilter filters messages based on whether their signatures are valid.

func NewMessageSignatureFilter

func NewMessageSignatureFilter() *MessageSignatureFilter

NewMessageSignatureFilter creates a new message signature filter.

func (*MessageSignatureFilter) Close added in v0.7.6

func (f *MessageSignatureFilter) Close() error

Close closes the filter.

func (*MessageSignatureFilter) Filter

func (f *MessageSignatureFilter) Filter(msg *Message, peer *peer.Peer)

Filter filters up on the given bytes and peer and calls the acceptance callback if the input passes or the rejection callback if the input is rejected.

func (*MessageSignatureFilter) OnAccept

func (f *MessageSignatureFilter) OnAccept(callback func(msg *Message, peer *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*MessageSignatureFilter) OnReject

func (f *MessageSignatureFilter) OnReject(callback func(msg *Message, err error, peer *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type MessageTestFramework added in v0.5.3

type MessageTestFramework struct {
	// contains filtered or unexported fields
}

MessageTestFramework implements a framework for conveniently issuing messages in a tangle as part of unit tests in a simplified way.

func NewMessageTestFramework added in v0.5.3

func NewMessageTestFramework(tangle *Tangle, options ...MessageTestFrameworkOption) (messageTestFramework *MessageTestFramework)

NewMessageTestFramework is the constructor of the MessageTestFramework.

func (*MessageTestFramework) BranchID added in v0.5.7

func (m *MessageTestFramework) BranchID(messageAlias string) ledgerstate.BranchID

BranchID returns the BranchID of the Transaction contained in the Message associated with the given alias.

func (*MessageTestFramework) CreateMessage added in v0.5.3

func (m *MessageTestFramework) CreateMessage(messageAlias string, messageOptions ...MessageOption) (message *Message)

CreateMessage creates a Message with the given alias and MessageTestFrameworkMessageOptions.

func (*MessageTestFramework) IncreaseMarkersIndexCallback added in v0.5.7

func (m *MessageTestFramework) IncreaseMarkersIndexCallback(markers.SequenceID, markers.Index) bool

IncreaseMarkersIndexCallback is the IncreaseMarkersIndexCallback that the MessageTestFramework uses to determine when to assign new Markers to messages.

func (*MessageTestFramework) IssueMessages added in v0.5.3

func (m *MessageTestFramework) IssueMessages(messageAliases ...string) *MessageTestFramework

IssueMessages stores the given Messages in the Storage and triggers the processing by the Tangle.

func (*MessageTestFramework) Message added in v0.5.3

func (m *MessageTestFramework) Message(alias string) (message *Message)

Message retrieves the Messages that is associated with the given alias.

func (*MessageTestFramework) MessageMetadata added in v0.5.7

func (m *MessageTestFramework) MessageMetadata(alias string) (messageMetadata *MessageMetadata)

MessageMetadata retrieves the MessageMetadata that is associated with the given alias.

func (*MessageTestFramework) PreventNewMarkers added in v0.5.7

func (m *MessageTestFramework) PreventNewMarkers(enabled bool) *MessageTestFramework

PreventNewMarkers disables the generation of new Markers for the given Messages.

func (*MessageTestFramework) TransactionID added in v0.5.7

func (m *MessageTestFramework) TransactionID(messageAlias string) ledgerstate.TransactionID

TransactionID returns the TransactionID of the Transaction contained in the Message associated with the given alias.

func (*MessageTestFramework) WaitApprovalWeightProcessed added in v0.5.7

func (m *MessageTestFramework) WaitApprovalWeightProcessed() *MessageTestFramework

WaitApprovalWeightProcessed waits for all Messages to be processed by the ApprovalWeightManager.

func (*MessageTestFramework) WaitMessagesBooked added in v0.5.3

func (m *MessageTestFramework) WaitMessagesBooked() *MessageTestFramework

WaitMessagesBooked waits for all Messages to be processed by the Booker.

type MessageTestFrameworkMessageOptions added in v0.5.3

type MessageTestFrameworkMessageOptions struct {
	// contains filtered or unexported fields
}

MessageTestFrameworkMessageOptions is a struct that represents a collection of options that can be set when creating a Message with the MessageTestFramework.

func NewMessageTestFrameworkMessageOptions added in v0.5.3

func NewMessageTestFrameworkMessageOptions(options ...MessageOption) (messageOptions *MessageTestFrameworkMessageOptions)

NewMessageTestFrameworkMessageOptions is the constructor for the MessageTestFrameworkMessageOptions.

type MessageTestFrameworkOption added in v0.5.3

type MessageTestFrameworkOption func(*MessageTestFrameworkOptions)

MessageTestFrameworkOption is the type that is used for options that can be passed into the MessageTestFramework to configure its behavior.

func WithColoredGenesisOutput added in v0.5.3

func WithColoredGenesisOutput(alias string, balances map[ledgerstate.Color]uint64) MessageTestFrameworkOption

WithColoredGenesisOutput returns a MessageTestFrameworkOption that defines a genesis Output that is loaded as part of the initial snapshot and that supports colored coins.

func WithGenesisOutput added in v0.5.3

func WithGenesisOutput(alias string, balance uint64) MessageTestFrameworkOption

WithGenesisOutput returns a MessageTestFrameworkOption that defines a genesis Output that is loaded as part of the initial snapshot.

type MessageTestFrameworkOptions added in v0.5.3

type MessageTestFrameworkOptions struct {
	// contains filtered or unexported fields
}

MessageTestFrameworkOptions is a container that holds the values of all configurable options of the MessageTestFramework.

func NewMessageTestFrameworkOptions added in v0.5.3

func NewMessageTestFrameworkOptions(options ...MessageTestFrameworkOption) (frameworkOptions *MessageTestFrameworkOptions)

NewMessageTestFrameworkOptions is the constructor for the MessageTestFrameworkOptions.

type MissingMessage

type MissingMessage struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

MissingMessage represents a missing message.

func MissingMessageFromBytes

func MissingMessageFromBytes(bytes []byte) (result *MissingMessage, consumedBytes int, err error)

MissingMessageFromBytes parses the given bytes into a MissingMessage.

func MissingMessageFromMarshalUtil

func MissingMessageFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result *MissingMessage, err error)

MissingMessageFromMarshalUtil parses a MissingMessage from the given MarshalUtil.

func NewMissingMessage

func NewMissingMessage(messageID MessageID) *MissingMessage

NewMissingMessage creates new missing message with the specified messageID.

func (*MissingMessage) Bytes

func (m *MissingMessage) Bytes() []byte

Bytes returns a marshaled version of this MissingMessage.

func (*MissingMessage) MessageID

func (m *MissingMessage) MessageID() MessageID

MessageID returns the id of the message.

func (*MissingMessage) MissingSince

func (m *MissingMessage) MissingSince() time.Time

MissingSince returns the time since when this message is missing.

func (*MissingMessage) ObjectStorageKey

func (m *MissingMessage) ObjectStorageKey() []byte

ObjectStorageKey returns the key of the stored missing message. This returns the bytes of the messageID of the missing message.

func (*MissingMessage) ObjectStorageValue

func (m *MissingMessage) ObjectStorageValue() (result []byte)

ObjectStorageValue returns the value of the stored missing message.

func (*MissingMessage) Update

func (m *MissingMessage) Update(other objectstorage.StorableObject)

Update update the missing message. It should never happen and will panic if called.

type Option

type Option func(*Options)

Option represents the return type of optional parameters that can be handed into the constructor of the Tangle to configure its behavior.

func ApprovalWeights added in v0.5.7

func ApprovalWeights(weightProvider WeightProvider) Option

ApprovalWeights is an Option for the Tangle that allows to define how the approval weights of Messages is determined.

func CacheTimeProvider added in v0.7.3

func CacheTimeProvider(cacheTimeProvider *database.CacheTimeProvider) Option

CacheTimeProvider is an Option for the Tangle that allows to override hard coded cache time.

func Consensus added in v0.5.0

func Consensus(consensusMechanism ConsensusMechanism) Option

Consensus is an Option for the Tangle that allows to define the consensus mechanism that is used by the Tangle.

func GenesisNode added in v0.5.2

func GenesisNode(genesisNodeBase58 string) Option

GenesisNode is an Option for the Tangle that allows to set the GenesisNode, i.e., the node that is allowed to attach to the Genesis Message.

func Identity added in v0.3.6

func Identity(identity *identity.LocalIdentity) Option

Identity is an Option for the Tangle that allows to specify the node identity which is used to issue Messages.

func IncreaseMarkersIndexCallback added in v0.4.0

func IncreaseMarkersIndexCallback(callback markers.IncreaseIndexCallback) Option

IncreaseMarkersIndexCallback is an Option for the Tangle that allows to change the strategy how new Markers are assigned in the Tangle.

func RateSetterConfig added in v0.6.2

func RateSetterConfig(params RateSetterParams) Option

RateSetterConfig is an Option for the Tangle that allows to set the rate setter.

func SchedulerConfig added in v0.6.2

func SchedulerConfig(config SchedulerParams) Option

SchedulerConfig is an Option for the Tangle that allows to set the scheduler.

func StartSynced added in v0.5.9

func StartSynced(startSynced bool) Option

StartSynced is an Option for the Tangle that allows to define if the node starts as synced.

func Store added in v0.3.6

func Store(store kvstore.KVStore) Option

Store is an Option for the Tangle that allows to specify which storage layer is supposed to be used to persist data.

func SyncTimeWindow added in v0.5.8

func SyncTimeWindow(syncTimeWindow time.Duration) Option

SyncTimeWindow is an Option for the Tangle that allows to define the time window in which the node will consider itself in sync.

func Width added in v0.5.2

func Width(width int) Option

Width is an Option for the Tangle that allows to change the strategy how Tips get removed.

type Options

type Options struct {
	Store                        kvstore.KVStore
	Identity                     *identity.LocalIdentity
	IncreaseMarkersIndexCallback markers.IncreaseIndexCallback
	TangleWidth                  int
	ConsensusMechanism           ConsensusMechanism
	GenesisNode                  *ed25519.PublicKey
	SchedulerParams              SchedulerParams
	RateSetterParams             RateSetterParams
	WeightProvider               WeightProvider
	SyncTimeWindow               time.Duration
	StartSynced                  bool
	CacheTimeProvider            *database.CacheTimeProvider
}

Options is a container for all configurable parameters of the Tangle.

type Orderer added in v0.6.2

type Orderer struct {
	Events *OrdererEvents
	// contains filtered or unexported fields
}

Orderer is a Tangle component that makes sure that no messages are booked without their parents being booked first.

func NewOrderer added in v0.6.2

func NewOrderer(tangle *Tangle) (orderer *Orderer)

NewOrderer is the constructor for Orderer.

func (*Orderer) Setup added in v0.6.2

func (o *Orderer) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*Orderer) Shutdown added in v0.6.2

func (o *Orderer) Shutdown()

Shutdown shuts down the Orderer and persists its state.

type OrdererEvents added in v0.6.2

type OrdererEvents struct {
	// MessageOrdered is triggered when a message is ordered and thus ready to be booked.
	MessageOrdered *events.Event
}

OrdererEvents represents events happening in the Orderer.

type Parent added in v0.3.1

type Parent struct {
	ID   MessageID
	Type uint8
}

Parent is a parent that can be either strong or weak.

type Parser added in v0.3.6

type Parser struct {
	Events *ParserEvents
	// contains filtered or unexported fields
}

Parser parses messages and bytes and emits corresponding events for parsed and rejected messages.

func NewParser added in v0.3.6

func NewParser() (result *Parser)

NewParser creates a new Message parser.

func (*Parser) AddBytesFilter added in v0.3.6

func (p *Parser) AddBytesFilter(filter BytesFilter)

AddBytesFilter adds the given bytes filter to the parser.

func (*Parser) AddMessageFilter added in v0.3.6

func (p *Parser) AddMessageFilter(filter MessageFilter)

AddMessageFilter adds a new message filter to the parser.

func (*Parser) Parse added in v0.3.6

func (p *Parser) Parse(messageBytes []byte, peer *peer.Peer)

Parse parses the given message bytes.

func (*Parser) Setup added in v0.3.6

func (p *Parser) Setup()

Setup defines the flow of the parser.

func (*Parser) Shutdown added in v0.7.6

func (p *Parser) Shutdown()

Shutdown closes all the message filters.

type ParserEvents added in v0.3.6

type ParserEvents struct {
	// Fired when a message was parsed.
	MessageParsed *events.Event

	// Fired when submitted bytes are rejected by a filter.
	BytesRejected *events.Event

	// Fired when a message got rejected by a filter.
	MessageRejected *events.Event
}

ParserEvents represents events happening in the Parser.

type PowFilter

type PowFilter struct {
	// contains filtered or unexported fields
}

PowFilter is a message bytes filter validating the PoW nonce.

func NewPowFilter

func NewPowFilter(worker *pow.Worker, difficulty int) *PowFilter

NewPowFilter creates a new PoW bytes filter.

func (*PowFilter) Filter

func (f *PowFilter) Filter(msgBytes []byte, p *peer.Peer)

Filter checks whether the given bytes pass the PoW validation and calls the corresponding callback.

func (*PowFilter) OnAccept

func (f *PowFilter) OnAccept(callback func([]byte, *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*PowFilter) OnReject

func (f *PowFilter) OnReject(callback func([]byte, error, *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type RateSetter added in v0.6.2

type RateSetter struct {
	Events *RateSetterEvents
	// contains filtered or unexported fields
}

RateSetter is a Tangle component that takes care of congestion control of local node.

func NewRateSetter added in v0.6.2

func NewRateSetter(tangle *Tangle) *RateSetter

NewRateSetter returns a new RateSetter.

func (*RateSetter) Issue added in v0.6.2

func (r *RateSetter) Issue(message *Message) error

Issue submits a message to the local issuing queue.

func (*RateSetter) Rate added in v0.6.2

func (r *RateSetter) Rate() float64

Rate returns the rate of the rate setter.

func (*RateSetter) Setup added in v0.6.2

func (r *RateSetter) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of the other components.

func (*RateSetter) Shutdown added in v0.6.2

func (r *RateSetter) Shutdown()

Shutdown shuts down the RateSetter.

func (*RateSetter) Size added in v0.6.2

func (r *RateSetter) Size() int

Size returns the size of the issuing queue.

type RateSetterEvents added in v0.6.2

type RateSetterEvents struct {
	MessageDiscarded *events.Event
}

RateSetterEvents represents events happening in the rate setter.

type RateSetterParams added in v0.6.2

type RateSetterParams struct {
	Initial *float64
}

RateSetterParams represents the parameters for RateSetter.

type RecentlySeenBytesFilter

type RecentlySeenBytesFilter struct {
	// contains filtered or unexported fields
}

RecentlySeenBytesFilter filters so that bytes which were recently seen don't pass the filter.

func NewRecentlySeenBytesFilter

func NewRecentlySeenBytesFilter() *RecentlySeenBytesFilter

NewRecentlySeenBytesFilter creates a new recently seen bytes filter.

func (*RecentlySeenBytesFilter) Filter

func (r *RecentlySeenBytesFilter) Filter(bytes []byte, peer *peer.Peer)

Filter filters up on the given bytes and peer and calls the acceptance callback if the input passes or the rejection callback if the input is rejected.

func (*RecentlySeenBytesFilter) OnAccept

func (r *RecentlySeenBytesFilter) OnAccept(callback func(bytes []byte, peer *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*RecentlySeenBytesFilter) OnReject

func (r *RecentlySeenBytesFilter) OnReject(callback func(bytes []byte, err error, peer *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type Requester added in v0.3.6

type Requester struct {
	Events *MessageRequesterEvents
	// contains filtered or unexported fields
}

Requester takes care of requesting messages.

func NewRequester added in v0.3.6

func NewRequester(tangle *Tangle, optionalOptions ...RequesterOption) *Requester

NewRequester creates a new message requester.

func (*Requester) RequestQueueSize added in v0.3.6

func (r *Requester) RequestQueueSize() int

RequestQueueSize returns the number of scheduled message requests.

func (*Requester) Setup added in v0.3.6

func (r *Requester) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*Requester) StartRequest added in v0.3.6

func (r *Requester) StartRequest(id MessageID)

StartRequest initiates a regular triggering of the StartRequest event until it has been stopped using StopRequest.

func (*Requester) StopRequest added in v0.3.6

func (r *Requester) StopRequest(id MessageID)

StopRequest stops requests for the given message to further happen.

type RequesterOption added in v0.3.6

type RequesterOption func(*RequesterOptions)

RequesterOption is a function which inits an option.

func RetryInterval

func RetryInterval(interval time.Duration) RequesterOption

RetryInterval creates an option which sets the retry interval to the given value.

type RequesterOptions added in v0.3.6

type RequesterOptions struct {
	// contains filtered or unexported fields
}

RequesterOptions holds options for a message requester.

type Scheduler added in v0.3.6

type Scheduler struct {
	Events *SchedulerEvents
	// contains filtered or unexported fields
}

Scheduler is a Tangle component that takes care of scheduling the messages that shall be booked.

func NewScheduler added in v0.3.6

func NewScheduler(tangle *Tangle) *Scheduler

NewScheduler returns a new Scheduler.

func (*Scheduler) Clear added in v0.6.2

func (s *Scheduler) Clear()

Clear removes all submitted messages (ready or not) from the scheduler. The MessageDiscarded event is triggered for each of these messages.

func (*Scheduler) NodeQueueSize added in v0.6.2

func (s *Scheduler) NodeQueueSize(nodeID identity.ID) int

NodeQueueSize returns the size of the nodeIDs queue.

func (*Scheduler) NodeQueueSizes added in v0.6.2

func (s *Scheduler) NodeQueueSizes() map[identity.ID]int

NodeQueueSizes returns the size for each node queue.

func (*Scheduler) Rate added in v0.6.2

func (s *Scheduler) Rate() time.Duration

Rate gets the rate of the scheduler.

func (*Scheduler) Ready added in v0.6.2

func (s *Scheduler) Ready(messageID MessageID) (err error)

Ready marks a previously submitted message as ready to be scheduled. If Ready is called without a previous Submit, it has no effect.

func (*Scheduler) Running added in v0.6.2

func (s *Scheduler) Running() bool

Running returns true if the scheduler has started.

func (*Scheduler) SetRate added in v0.6.2

func (s *Scheduler) SetRate(rate time.Duration)

SetRate sets the rate of the scheduler.

func (*Scheduler) Setup added in v0.3.6

func (s *Scheduler) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of the other components.

func (*Scheduler) Shutdown added in v0.3.6

func (s *Scheduler) Shutdown()

Shutdown shuts down the Scheduler. Shutdown blocks until the scheduler has been shutdown successfully.

func (*Scheduler) Start added in v0.6.2

func (s *Scheduler) Start()

Start starts the scheduler.

func (*Scheduler) Submit added in v0.6.2

func (s *Scheduler) Submit(messageID MessageID) (err error)

Submit submits a message to be considered by the scheduler. This transactions will be included in all the control metrics, but it will never be scheduled until Ready(messageID) has been called.

func (*Scheduler) SubmitAndReady added in v0.6.2

func (s *Scheduler) SubmitAndReady(messageID MessageID) (err error)

SubmitAndReady submits the message to the scheduler and marks it ready right away.

func (*Scheduler) Unsubmit added in v0.6.2

func (s *Scheduler) Unsubmit(messageID MessageID) (err error)

Unsubmit removes a message from the submitted messages. If that message is already marked as ready, Unsubmit has no effect.

type SchedulerEvents added in v0.3.6

type SchedulerEvents struct {
	// MessageScheduled is triggered when a message is ready to be scheduled.
	MessageScheduled *events.Event
	MessageDiscarded *events.Event
	NodeBlacklisted  *events.Event
	Error            *events.Event
}

SchedulerEvents represents events happening in the Scheduler.

type SchedulerParams added in v0.6.2

type SchedulerParams struct {
	MaxBufferSize               int
	Rate                        time.Duration
	AccessManaRetrieveFunc      func(identity.ID) float64
	TotalAccessManaRetrieveFunc func() float64
}

SchedulerParams defines the scheduler config parameters.

type SendRequestEvent

type SendRequestEvent struct {
	ID MessageID
}

SendRequestEvent represents the parameters of sendRequestEventHandler

type SequenceSupporters added in v0.5.7

type SequenceSupporters struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

SequenceSupporters is a data structure that tracks which nodes have confirmed which Index in a given Sequence.

func NewSequenceSupporters added in v0.5.7

func NewSequenceSupporters(sequenceID markers.SequenceID) (sequenceSupporters *SequenceSupporters)

NewSequenceSupporters is the constructor for the SequenceSupporters object.

func SequenceSupportersFromBytes added in v0.5.7

func SequenceSupportersFromBytes(bytes []byte) (sequenceSupporters *SequenceSupporters, consumedBytes int, err error)

SequenceSupportersFromBytes unmarshals a SequenceSupporters object from a sequence of bytes.

func SequenceSupportersFromMarshalUtil added in v0.5.7

func SequenceSupportersFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (sequenceSupporters *SequenceSupporters, err error)

SequenceSupportersFromMarshalUtil unmarshals a SequenceSupporters object using a MarshalUtil (for easier unmarshaling).

func (*SequenceSupporters) AddSupporter added in v0.5.7

func (s *SequenceSupporters) AddSupporter(supporter Supporter, index markers.Index) (added bool)

AddSupporter adds a new Supporter of a given index to the Sequence.

func (*SequenceSupporters) Bytes added in v0.5.7

func (s *SequenceSupporters) Bytes() (marshaledSequenceSupporters []byte)

Bytes returns a marshaled version of the SequenceSupporters.

func (*SequenceSupporters) ObjectStorageKey added in v0.5.7

func (s *SequenceSupporters) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*SequenceSupporters) ObjectStorageValue added in v0.5.7

func (s *SequenceSupporters) ObjectStorageValue() []byte

ObjectStorageValue marshals the SequenceSupporters into a sequence of bytes that are used as the value part in the object storage.

func (*SequenceSupporters) SequenceID added in v0.5.7

func (s *SequenceSupporters) SequenceID() (sequenceID markers.SequenceID)

SequenceID returns the SequenceID that is being tracked.

func (*SequenceSupporters) String added in v0.5.7

func (s *SequenceSupporters) String() string

String returns a human readable version of the SequenceSupporters.

func (*SequenceSupporters) Supporters added in v0.5.7

func (s *SequenceSupporters) Supporters(index markers.Index) (supporters *Supporters)

Supporters returns the set of Supporters that have approved the given Index.

func (*SequenceSupporters) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

type Solidifier added in v0.3.6

type Solidifier struct {
	// Events contains the Solidifier related events.
	Events *SolidifierEvents
	// contains filtered or unexported fields
}

Solidifier is the Tangle's component that solidifies messages.

func NewSolidifier added in v0.3.6

func NewSolidifier(tangle *Tangle) (solidifier *Solidifier)

NewSolidifier is the constructor of the Solidifier.

func (*Solidifier) Setup added in v0.3.6

func (s *Solidifier) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of the other components.

func (*Solidifier) Solidify added in v0.3.6

func (s *Solidifier) Solidify(messageID MessageID)

Solidify solidifies the given Message.

type SolidifierEvents added in v0.3.6

type SolidifierEvents struct {
	// MessageSolid is triggered when a message becomes solid, i.e. its past cone is known and solid.
	MessageSolid *events.Event

	// MessageMissing is triggered when a message references an unknown parent Message.
	MessageMissing *events.Event
}

SolidifierEvents represents events happening in the Solidifier.

type Statement added in v0.5.7

type Statement struct {
	objectstorage.StorableObjectFlags
	// contains filtered or unexported fields
}

Statement is a data structure that tracks the latest statement by a Supporter per ledgerstate.BranchID.

func NewStatement added in v0.5.7

func NewStatement(branchID ledgerstate.BranchID, supporter Supporter) (statement *Statement)

NewStatement creates a new Statement

func StatementFromBytes added in v0.5.7

func StatementFromBytes(bytes []byte) (statement *Statement, consumedBytes int, err error)

StatementFromBytes unmarshals a SequenceSupporters object from a sequence of bytes.

func StatementFromMarshalUtil added in v0.5.7

func StatementFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (statement *Statement, err error)

StatementFromMarshalUtil unmarshals a Statement object using a MarshalUtil (for easier unmarshaling).

func (*Statement) BranchID added in v0.5.7

func (s *Statement) BranchID() (branchID ledgerstate.BranchID)

BranchID returns the ledgerstate.BranchID that is being tracked.

func (*Statement) Bytes added in v0.5.7

func (s *Statement) Bytes() (marshaledSequenceSupporters []byte)

Bytes returns a marshaled version of the Statement.

func (*Statement) ObjectStorageKey added in v0.5.7

func (s *Statement) ObjectStorageKey() []byte

ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.

func (*Statement) ObjectStorageValue added in v0.5.7

func (s *Statement) ObjectStorageValue() []byte

ObjectStorageValue marshals the Statement into a sequence of bytes that are used as the value part in the object storage.

func (*Statement) SequenceNumber added in v0.5.7

func (s *Statement) SequenceNumber() (sequenceNumber uint64)

SequenceNumber returns the sequence number of the Statement.

func (*Statement) String added in v0.5.7

func (s *Statement) String() string

String returns a human readable version of the Statement.

func (*Statement) Supporter added in v0.5.7

func (s *Statement) Supporter() (supporter Supporter)

Supporter returns the Supporter that is being tracked.

func (*Statement) Update added in v0.5.7

Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.

func (*Statement) UpdateSequenceNumber added in v0.5.7

func (s *Statement) UpdateSequenceNumber(sequenceNumber uint64) (updated bool)

UpdateSequenceNumber updates the sequence number of the Statement if it is greater than the currently stored sequence number and returns true if it was updated.

type Storage added in v0.3.6

type Storage struct {
	Events *StorageEvents
	// contains filtered or unexported fields
}

Storage represents the storage of messages.

func NewStorage added in v0.3.6

func NewStorage(tangle *Tangle) (storage *Storage)

NewStorage creates a new Storage.

func (*Storage) Approvers added in v0.3.6

func (s *Storage) Approvers(messageID MessageID, optionalApproverType ...ApproverType) (cachedApprovers CachedApprovers)

Approvers retrieves the Approvers of a Message from the object storage. It is possible to provide an optional ApproverType to only return the corresponding Approvers.

func (*Storage) AttachmentMessageIDs added in v0.3.6

func (s *Storage) AttachmentMessageIDs(transactionID ledgerstate.TransactionID) (messageIDs MessageIDs)

AttachmentMessageIDs returns the messageIDs of the transaction in attachmentStorage.

func (*Storage) Attachments added in v0.3.6

func (s *Storage) Attachments(transactionID ledgerstate.TransactionID) (cachedAttachments CachedAttachments)

Attachments retrieves the attachment of a transaction in attachmentStorage.

func (*Storage) BranchSupporters added in v0.5.7

func (s *Storage) BranchSupporters(branchID ledgerstate.BranchID, computeIfAbsentCallback ...func(branchID ledgerstate.BranchID) *BranchSupporters) *CachedBranchSupporters

BranchSupporters retrieves the BranchSupporters with the given ledgerstate.BranchID.

func (*Storage) BranchWeight added in v0.5.7

func (s *Storage) BranchWeight(branchID ledgerstate.BranchID, computeIfAbsentCallback ...func(branchID ledgerstate.BranchID) *BranchWeight) *CachedBranchWeight

BranchWeight retrieves the BranchWeight with the given ledgerstate.BranchID.

func (*Storage) DBStats added in v0.3.6

func (s *Storage) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64, missingMessageCount int)

DBStats returns the number of solid messages and total number of messages in the database (messageMetadataStorage, that should contain the messages as messageStorage), the number of messages in missingMessageStorage, furthermore the average time it takes to solidify messages.

func (*Storage) DeleteIndividuallyMappedMessage added in v0.5.7

func (s *Storage) DeleteIndividuallyMappedMessage(branchID ledgerstate.BranchID, messageID MessageID)

DeleteIndividuallyMappedMessage deleted an IndividuallyMappedMessage in the underlying object storage.

func (*Storage) DeleteMarkerMessageMapping added in v0.5.7

func (s *Storage) DeleteMarkerMessageMapping(branchID ledgerstate.BranchID, messageID MessageID)

DeleteMarkerMessageMapping deleted a MarkerMessageMapping in the underlying object storage.

func (*Storage) DeleteMessage added in v0.3.6

func (s *Storage) DeleteMessage(messageID MessageID)

DeleteMessage deletes a message and its association to approvees by un-marking the given message as an approver.

func (*Storage) DeleteMissingMessage added in v0.3.6

func (s *Storage) DeleteMissingMessage(messageID MessageID)

DeleteMissingMessage deletes a message from the missingMessageStorage.

func (*Storage) IndividuallyMappedMessage added in v0.5.7

func (s *Storage) IndividuallyMappedMessage(branchID ledgerstate.BranchID, messageID MessageID) (cachedIndividuallyMappedMessages *CachedIndividuallyMappedMessage)

IndividuallyMappedMessage retrieves the IndividuallyMappedMessage associated with the given details.

func (*Storage) IndividuallyMappedMessages added in v0.5.7

func (s *Storage) IndividuallyMappedMessages(branchID ledgerstate.BranchID) (cachedIndividuallyMappedMessages CachedIndividuallyMappedMessages)

IndividuallyMappedMessages retrieves the IndividuallyMappedMessages of a Branch in the object storage.

func (*Storage) IsTransactionAttachedByMessage added in v0.4.0

func (s *Storage) IsTransactionAttachedByMessage(transactionID ledgerstate.TransactionID, messageID MessageID) (attached bool)

IsTransactionAttachedByMessage checks whether Transaction with transactionID is attached by Message with messageID.

func (*Storage) MarkerIndexBranchIDMapping added in v0.3.6

func (s *Storage) MarkerIndexBranchIDMapping(sequenceID markers.SequenceID, computeIfAbsentCallback ...func(sequenceID markers.SequenceID) *MarkerIndexBranchIDMapping) *CachedMarkerIndexBranchIDMapping

MarkerIndexBranchIDMapping retrieves the MarkerIndexBranchIDMapping for the given SequenceID. It accepts an optional computeIfAbsent callback that can be used to dynamically create a MarkerIndexBranchIDMapping if it doesn't exist, yet.

func (*Storage) MarkerMessageMapping added in v0.5.7

func (s *Storage) MarkerMessageMapping(marker *markers.Marker) (cachedMarkerMessageMappings *CachedMarkerMessageMapping)

MarkerMessageMapping retrieves the MarkerMessageMapping associated with the given details.

func (*Storage) MarkerMessageMappings added in v0.5.7

func (s *Storage) MarkerMessageMappings(sequenceID markers.SequenceID) (cachedMarkerMessageMappings CachedMarkerMessageMappings)

MarkerMessageMappings retrieves the MarkerMessageMappings of a Sequence in the object storage.

func (*Storage) Message added in v0.3.6

func (s *Storage) Message(messageID MessageID) *CachedMessage

Message retrieves a message from the message store.

func (*Storage) MessageMetadata added in v0.3.6

func (s *Storage) MessageMetadata(messageID MessageID, computeIfAbsentCallback ...func() *MessageMetadata) *CachedMessageMetadata

MessageMetadata retrieves the MessageMetadata with the given MessageID.

func (*Storage) MissingMessages added in v0.3.6

func (s *Storage) MissingMessages() (ids []MessageID)

MissingMessages return the ids of messages in missingMessageStorage

func (*Storage) Prune added in v0.3.6

func (s *Storage) Prune() error

Prune resets the database and deletes all objects (good for testing or "node resets").

func (*Storage) RetrieveAllTips added in v0.3.6

func (s *Storage) RetrieveAllTips() (tips []MessageID)

RetrieveAllTips returns the tips (i.e., solid messages that are not part of the approvers list). It iterates over the messageMetadataStorage, thus only use this method if necessary. TODO: improve this function.

func (*Storage) SequenceSupporters added in v0.5.7

func (s *Storage) SequenceSupporters(sequenceID markers.SequenceID, computeIfAbsentCallback ...func() *SequenceSupporters) *CachedSequenceSupporters

SequenceSupporters retrieves the SequenceSupporters with the given SequenceID.

func (*Storage) Setup added in v0.3.6

func (s *Storage) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*Storage) Shutdown added in v0.3.6

func (s *Storage) Shutdown()

Shutdown marks the tangle as stopped, so it will not accept any new messages (waits for all backgroundTasks to finish).

func (*Storage) Statement added in v0.5.7

func (s *Storage) Statement(branchID ledgerstate.BranchID, supporter Supporter, computeIfAbsentCallback ...func() *Statement) *CachedStatement

Statement retrieves the Statement with the given ledgerstate.BranchID and Supporter.

func (*Storage) StoreAttachment added in v0.3.6

func (s *Storage) StoreAttachment(transactionID ledgerstate.TransactionID, messageID MessageID) (cachedAttachment *CachedAttachment, stored bool)

StoreAttachment stores a new attachment if not already stored.

func (*Storage) StoreIndividuallyMappedMessage added in v0.5.7

func (s *Storage) StoreIndividuallyMappedMessage(individuallyMappedMessage *IndividuallyMappedMessage)

StoreIndividuallyMappedMessage stores an IndividuallyMappedMessage in the underlying object storage.

func (*Storage) StoreMarkerMessageMapping added in v0.5.7

func (s *Storage) StoreMarkerMessageMapping(markerMessageMapping *MarkerMessageMapping)

StoreMarkerMessageMapping stores a MarkerMessageMapping in the underlying object storage.

func (*Storage) StoreMessage added in v0.3.6

func (s *Storage) StoreMessage(message *Message)

StoreMessage stores a new message to the message store.

func (*Storage) StoreMissingMessage added in v0.3.6

func (s *Storage) StoreMissingMessage(missingMessage *MissingMessage) (cachedMissingMessage *CachedMissingMessage, stored bool)

StoreMissingMessage stores a new MissingMessage entry in the object storage.

type StorageEvents added in v0.3.6

type StorageEvents struct {
	// Fired when a message has been stored.
	MessageStored *events.Event

	// Fired when a message was removed from storage.
	MessageRemoved *events.Event

	// Fired when a message which was previously marked as missing was received.
	MissingMessageStored *events.Event
}

StorageEvents represents events happening on the message store.

type Supporter added in v0.5.7

type Supporter = identity.ID

Supporter is a type wrapper for identity.ID and defines a node that supports a branch or marker.

type Supporters added in v0.5.7

type Supporters struct {
	set.Set
}

Supporters is a set of node identities that votes for a particular Branch.

func NewSupporters added in v0.5.7

func NewSupporters() (supporters *Supporters)

NewSupporters is the constructor of the Supporters type.

func (*Supporters) Add added in v0.5.7

func (s *Supporters) Add(supporter Supporter) (added bool)

Add adds a new Supporter to the Set and returns true if the Supporter was not present in the set before.

func (*Supporters) Clone added in v0.5.7

func (s *Supporters) Clone() (clonedSupporters *Supporters)

Clone returns a copy of the Supporters.

func (*Supporters) Delete added in v0.5.7

func (s *Supporters) Delete(supporter Supporter) (deleted bool)

Delete removes the Supporter from the Set and returns true if it did exist.

func (*Supporters) ForEach added in v0.5.7

func (s *Supporters) ForEach(callback func(supporter Supporter))

ForEach iterates through the Supporters and calls the callback for every element.

func (*Supporters) Has added in v0.5.7

func (s *Supporters) Has(supporter Supporter) (has bool)

Has returns true if the Supporter exists in the Set.

func (*Supporters) Intersect added in v0.5.7

func (s *Supporters) Intersect(other *Supporters) (intersection *Supporters)

Intersect creates an intersection of two set of Supporters.

func (*Supporters) String added in v0.5.7

func (s *Supporters) String() string

String returns a human readable version of the Supporters.

type SyncChangedEvent added in v0.6.0

type SyncChangedEvent struct {
	Synced bool
}

SyncChangedEvent represents a sync changed event.

type Tangle

type Tangle struct {
	Options               *Options
	Parser                *Parser
	Storage               *Storage
	Solidifier            *Solidifier
	Scheduler             *Scheduler
	Orderer               *Orderer
	Booker                *Booker
	ApprovalWeightManager *ApprovalWeightManager
	TimeManager           *TimeManager
	ConsensusManager      *ConsensusManager
	TipManager            *TipManager
	Requester             *Requester
	MessageFactory        *MessageFactory
	LedgerState           *LedgerState
	Utils                 *Utils
	WeightProvider        WeightProvider
	Events                *Events
	// contains filtered or unexported fields
}

Tangle is the central data structure of the IOTA protocol.

func New

func New(options ...Option) (tangle *Tangle)

New is the constructor for the Tangle.

func (*Tangle) Configure added in v0.5.0

func (t *Tangle) Configure(options ...Option)

Configure modifies the configuration of the Tangle.

func (*Tangle) IssuePayload added in v0.5.0

func (t *Tangle) IssuePayload(p payload.Payload, parentsCount ...int) (message *Message, err error)

IssuePayload allows to attach a payload (i.e. a Transaction) to the Tangle.

func (*Tangle) ProcessGossipMessage added in v0.3.6

func (t *Tangle) ProcessGossipMessage(messageBytes []byte, peer *peer.Peer)

ProcessGossipMessage is used to feed new Messages from the gossip layer into the Tangle.

func (*Tangle) Prune

func (t *Tangle) Prune() (err error)

Prune resets the database and deletes all stored objects (good for testing or "node resets").

func (*Tangle) Setup added in v0.3.6

func (t *Tangle) Setup()

Setup sets up the data flow by connecting the different components (by calling their corresponding Setup method).

func (*Tangle) Shutdown

func (t *Tangle) Shutdown()

Shutdown marks the tangle as stopped, so it will not accept any new messages (waits for all backgroundTasks to finish).

func (*Tangle) Synced added in v0.5.0

func (t *Tangle) Synced() (synced bool)

Synced returns a boolean value that indicates if the node is fully synced and the Tangle has solidified all messages until the genesis.

type TimeManager added in v0.5.8

type TimeManager struct {
	Events *TimeManagerEvents
	// contains filtered or unexported fields
}

TimeManager is a Tangle component that keeps track of the TangleTime. The TangleTime can be seen as a clock for the entire network as it tracks the time of the last confirmed message. Comparing the issuing time of the last confirmed message to the node's current wall clock time then yields a reasonable assessment of how much in sync the node is.

func NewTimeManager added in v0.5.8

func NewTimeManager(tangle *Tangle) *TimeManager

NewTimeManager is the constructor for TimeManager.

func (*TimeManager) LastConfirmedMessage added in v0.5.8

func (t *TimeManager) LastConfirmedMessage() LastConfirmedMessage

LastConfirmedMessage returns the last confirmed message.

func (*TimeManager) Setup added in v0.5.8

func (t *TimeManager) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*TimeManager) Shutdown added in v0.5.8

func (t *TimeManager) Shutdown()

Shutdown shuts down the TimeManager and persists its state.

func (*TimeManager) Start added in v0.7.3

func (t *TimeManager) Start()

Start starts the TimeManager.

func (*TimeManager) Synced added in v0.5.8

func (t *TimeManager) Synced() bool

Synced returns whether the node is in sync based on the difference between TangleTime and current wall time which can be configured via SyncTimeWindow.

func (*TimeManager) Time added in v0.5.8

func (t *TimeManager) Time() time.Time

Time returns the TangleTime, i.e., the issuing time of the last confirmed message.

type TimeManagerEvents added in v0.6.0

type TimeManagerEvents struct {
	// Fired when the nodes sync status changes.
	SyncChanged *events.Event
}

TimeManagerEvents represents events happening in the TimeManager.

type TimeRetrieverFunc added in v0.5.8

type TimeRetrieverFunc func() time.Time

TimeRetrieverFunc is a function type to retrieve the time.

type TimedTaskExecutor added in v0.5.1

type TimedTaskExecutor struct {
	*timedexecutor.TimedExecutor
	// contains filtered or unexported fields
}

TimedTaskExecutor is a TimedExecutor that internally manages the scheduled callbacks as tasks with a unique identifier. It allows to replace existing scheduled tasks and cancel them using the same identifier.

func NewTimedTaskExecutor added in v0.5.1

func NewTimedTaskExecutor(workerCount int) *TimedTaskExecutor

NewTimedTaskExecutor is the constructor of the TimedTaskExecutor.

func (*TimedTaskExecutor) Cancel added in v0.5.1

func (t *TimedTaskExecutor) Cancel(identifier interface{}) (canceled bool)

Cancel cancels a queued task.

func (*TimedTaskExecutor) ExecuteAfter added in v0.5.1

func (t *TimedTaskExecutor) ExecuteAfter(identifier interface{}, callback func(), delay time.Duration) *timedexecutor.ScheduledTask

ExecuteAfter executes the given function after the given delay.

func (*TimedTaskExecutor) ExecuteAt added in v0.5.1

func (t *TimedTaskExecutor) ExecuteAt(identifier interface{}, callback func(), executionTime time.Time) *timedexecutor.ScheduledTask

ExecuteAt executes the given function at the given time.

type TimestampFilter added in v0.7.6

type TimestampFilter struct {
	// contains filtered or unexported fields
}

TimestampFilter is the filter to not process messages with timestamp in the future.

func NewTimestampFilter added in v0.7.6

func NewTimestampFilter() *TimestampFilter

NewTimestampFilter creates a new message timestamp filter.

func (*TimestampFilter) Close added in v0.7.6

func (f *TimestampFilter) Close() error

Close closes the filter.

func (*TimestampFilter) Filter added in v0.7.6

func (f *TimestampFilter) Filter(msg *Message, p *peer.Peer)

Filter filters up on the given bytes and peer and calls the acceptance callback if the input passes or the rejection callback if the input is rejected.

func (*TimestampFilter) OnAccept added in v0.7.6

func (f *TimestampFilter) OnAccept(callback func(msg *Message, p *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*TimestampFilter) OnReject added in v0.7.6

func (f *TimestampFilter) OnReject(callback func(msg *Message, err error, p *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type TipEvent added in v0.4.0

type TipEvent struct {
	// MessageID of the added/removed tip.
	MessageID MessageID

	// TipType is the type of the added/removed tip.
	TipType TipType
}

TipEvent holds the information provided by the TipEvent event that gets triggered when a message gets added or removed as tip.

type TipManager added in v0.3.6

type TipManager struct {
	Events *TipManagerEvents
	// contains filtered or unexported fields
}

TipManager manages a map of tips and emits events for their removal and addition.

func NewTipManager added in v0.3.6

func NewTipManager(tangle *Tangle, tips ...MessageID) *TipManager

NewTipManager creates a new tip-selector.

func (*TipManager) AddTip added in v0.3.6

func (t *TipManager) AddTip(message *Message)

AddTip first checks whether the message is eligible and its payload liked. If yes, then the given message is added as a strong or weak tip depending on its branch status. Parents of a message that are currently tip lose the tip status and are removed.

func (*TipManager) AllStrongTips added in v0.5.4

func (t *TipManager) AllStrongTips() MessageIDs

AllStrongTips returns a list of all strong tips that are stored in the TipManger.

func (*TipManager) AllWeakTips added in v0.5.4

func (t *TipManager) AllWeakTips() MessageIDs

AllWeakTips returns a list of all weak tips that are stored in the TipManger.

func (*TipManager) Set added in v0.3.6

func (t *TipManager) Set(tips ...MessageID)

Set adds the given messageIDs as tips.

func (*TipManager) Setup added in v0.3.6

func (t *TipManager) Setup()

Setup sets up the behavior of the component by making it attach to the relevant events of other components.

func (*TipManager) Shutdown added in v0.5.1

func (t *TipManager) Shutdown()

Shutdown stops the TipManager.

func (*TipManager) StrongTipCount added in v0.4.0

func (t *TipManager) StrongTipCount() int

StrongTipCount the amount of strong tips.

func (*TipManager) Tips added in v0.3.6

func (t *TipManager) Tips(p payload.Payload, countStrongParents, countWeakParents int) (strongParents, weakParents MessageIDs, err error)

Tips returns count number of tips, maximum MaxParentsCount.

func (*TipManager) WeakTipCount added in v0.4.0

func (t *TipManager) WeakTipCount() int

WeakTipCount the amount of weak tips.

type TipManagerEvents added in v0.3.6

type TipManagerEvents struct {
	// Fired when a tip is added.
	TipAdded *events.Event

	// Fired when a tip is removed.
	TipRemoved *events.Event
}

TipManagerEvents represents events happening on the TipManager.

type TipSelector

type TipSelector interface {
	Tips(p payload.Payload, countStrongParents, countWeakParents int) (strongParents, weakParents MessageIDs, err error)
}

A TipSelector selects two tips, parent2 and parent1, for a new message to attach to.

type TipSelectorFunc

type TipSelectorFunc func(p payload.Payload, countStrongParents, countWeakParents int) (strongParents, weakParents MessageIDs, err error)

The TipSelectorFunc type is an adapter to allow the use of ordinary functions as tip selectors.

func (TipSelectorFunc) Tips

func (f TipSelectorFunc) Tips(p payload.Payload, countStrongParents, countWeakParents int) (strongParents, weakParents MessageIDs, err error)

Tips calls f().

type TipType added in v0.4.0

type TipType uint8

TipType is the type (weak/strong) of the tip.

const (
	// StrongTip is the TipType that represents strong tips, i.e., eligible messages that are in a monotonically liked branch.
	StrongTip TipType = iota

	// WeakTip is the TipType that represents weak tips, i.e., eligible messages that are in a not monotonically liked branch.
	WeakTip
)

func (TipType) String added in v0.4.0

func (t TipType) String() string

String returns a human readable version of the TipType.

type TransactionFilter added in v0.3.6

type TransactionFilter struct {
	// contains filtered or unexported fields
}

TransactionFilter filters messages based on their timestamps and transaction timestamp.

func NewTransactionFilter added in v0.3.6

func NewTransactionFilter() *TransactionFilter

NewTransactionFilter creates a new transaction filter.

func (*TransactionFilter) Close added in v0.7.6

func (f *TransactionFilter) Close() error

Close closes the filter.

func (*TransactionFilter) Filter added in v0.3.6

func (f *TransactionFilter) Filter(msg *Message, peer *peer.Peer)

Filter compares the timestamps between the message and it's transaction payload and calls the corresponding callback.

func (*TransactionFilter) OnAccept added in v0.3.6

func (f *TransactionFilter) OnAccept(callback func(msg *Message, peer *peer.Peer))

OnAccept registers the given callback as the acceptance function of the filter.

func (*TransactionFilter) OnReject added in v0.3.6

func (f *TransactionFilter) OnReject(callback func(msg *Message, err error, peer *peer.Peer))

OnReject registers the given callback as the rejection function of the filter.

type Utils added in v0.3.6

type Utils struct {
	// contains filtered or unexported fields
}

Utils is a Tangle component that bundles methods that can be used to interact with the Tangle, that do not belong into public API.

func NewUtils added in v0.3.6

func NewUtils(tangle *Tangle) (utils *Utils)

NewUtils is the constructor of the Utils component.

func (*Utils) AllTransactionsApprovedByMessages added in v0.4.1

func (u *Utils) AllTransactionsApprovedByMessages(transactionIDs ledgerstate.TransactionIDs, messageIDs ...MessageID) (approved bool)

AllTransactionsApprovedByMessages checks if all Transactions were attached by at least one Message that was directly or indirectly approved by the given Message.

func (*Utils) ApprovingMessageIDs added in v0.3.6

func (u *Utils) ApprovingMessageIDs(messageID MessageID, optionalApproverType ...ApproverType) (approvingMessageIDs MessageIDs)

ApprovingMessageIDs returns the MessageIDs that approve a given Message. It accepts an optional ApproverType to filter the Approvers.

func (*Utils) ComputeIfTransaction added in v0.3.6

func (u *Utils) ComputeIfTransaction(messageID MessageID, compute func(ledgerstate.TransactionID)) (computed bool)

ComputeIfTransaction computes the given callback if the given messageID contains a transaction.

func (*Utils) MessageApprovedBy added in v0.3.6

func (u *Utils) MessageApprovedBy(approvedMessageID MessageID, approvingMessageID MessageID) (approved bool)

MessageApprovedBy checks if the Message given by approvedMessageID is directly or indirectly approved by the Message given by approvingMessageID.

func (*Utils) TransactionApprovedByMessage added in v0.4.0

func (u *Utils) TransactionApprovedByMessage(transactionID ledgerstate.TransactionID, messageID MessageID) (approved bool)

TransactionApprovedByMessage checks if the Transaction was attached by at least one Message that was directly or indirectly approved by the given Message.

func (*Utils) WalkMessage added in v0.3.6

func (u *Utils) WalkMessage(callback func(message *Message, walker *walker.Walker), entryPoints MessageIDs, revisitElements ...bool)

WalkMessage is a generic Tangle walker that executes a custom callback for every visited Message, starting from the given entry points. It accepts an optional boolean parameter which can be set to true if a Message should be visited more than once following different paths. The callback receives a Walker object as the last parameter which can be used to control the behavior of the walk similar to how a "Context" is used in some parts of the stdlib.

func (*Utils) WalkMessageAndMetadata added in v0.3.6

func (u *Utils) WalkMessageAndMetadata(callback func(message *Message, messageMetadata *MessageMetadata, walker *walker.Walker), entryPoints MessageIDs, revisitElements ...bool)

WalkMessageAndMetadata is a generic Tangle walker that executes a custom callback for every visited Message and MessageMetadata, starting from the given entry points. It accepts an optional boolean parameter which can be set to true if a Message should be visited more than once following different paths. The callback receives a Walker object as the last parameter which can be used to control the behavior of the walk similar to how a "Context" is used in some parts of the stdlib.

func (*Utils) WalkMessageID added in v0.3.6

func (u *Utils) WalkMessageID(callback func(messageID MessageID, walker *walker.Walker), entryPoints MessageIDs, revisitElements ...bool)

WalkMessageID is a generic Tangle walker that executes a custom callback for every visited MessageID, starting from the given entry points. It accepts an optional boolean parameter which can be set to true if a Message should be visited more than once following different paths. The callback receives a Walker object as the last parameter which can be used to control the behavior of the walk similar to how a "Context" is used in some parts of the stdlib.

func (*Utils) WalkMessageMetadata added in v0.3.6

func (u *Utils) WalkMessageMetadata(callback func(messageMetadata *MessageMetadata, walker *walker.Walker), entryPoints MessageIDs, revisitElements ...bool)

WalkMessageMetadata is a generic Tangle walker that executes a custom callback for every visited MessageMetadata, starting from the given entry points. It accepts an optional boolean parameter which can be set to true if a Message should be visited more than once following different paths. The callback receives a Walker object as the last parameter which can be used to control the behavior of the walk similar to how a "Context" is used in some parts of the stdlib.

type WeightProvider added in v0.5.7

type WeightProvider interface {
	// Update updates the underlying data structure and keeps track of active nodes.
	Update(t time.Time, nodeID identity.ID)

	// Weight returns the weight and total weight for the given message.
	Weight(message *Message) (weight, totalWeight float64)

	// WeightsOfRelevantSupporters returns all relevant weights.
	WeightsOfRelevantSupporters() (weights map[identity.ID]float64, totalWeight float64)

	// Shutdown shuts down the WeightProvider and persists its state.
	Shutdown()
}

WeightProvider is an interface that allows the ApprovalWeightManager to determine approval weights of Messages in a flexible way, independently of a specific implementation.

type Worker

type Worker interface {
	DoPOW([]byte) (nonce uint64, err error)
}

A Worker performs the PoW for the provided message in serialized byte form.

type WorkerFunc

type WorkerFunc func([]byte) (uint64, error)

The WorkerFunc type is an adapter to allow the use of ordinary functions as a PoW performer.

func (WorkerFunc) DoPOW

func (f WorkerFunc) DoPOW(msg []byte) (uint64, error)

DoPOW calls f(msg).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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