Documentation ¶
Index ¶
- Constants
- Variables
- func ApproverFromObjectStorage(key []byte, _ []byte) (result objectstorage.StorableObject, err error)
- func AttachmentFromObjectStorage(key []byte, _ []byte) (result objectstorage.StorableObject, err error)
- func MarkerIndexBranchIDMappingFromObjectStorage(key []byte, data []byte) (markerIndexBranchIDMapping objectstorage.StorableObject, err error)
- func MessageFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
- func MessageMetadataFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
- func MissingMessageFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
- func OpinionFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
- type Approver
- func (a *Approver) ApproverMessageID() MessageID
- func (a *Approver) Bytes() []byte
- func (a *Approver) ObjectStorageKey() []byte
- func (a *Approver) ObjectStorageValue() (result []byte)
- func (a *Approver) ReferencedMessageID() MessageID
- func (a *Approver) String() string
- func (a *Approver) Type() ApproverType
- func (a *Approver) Update(other objectstorage.StorableObject)
- type ApproverType
- type Attachment
- func (a *Attachment) Bytes() []byte
- func (a *Attachment) MessageID() MessageID
- func (a *Attachment) ObjectStorageKey() []byte
- func (a *Attachment) ObjectStorageValue() (data []byte)
- func (a *Attachment) String() string
- func (a *Attachment) TransactionID() ledgerstate.TransactionID
- func (a *Attachment) Update(other objectstorage.StorableObject)
- type Booker
- type BookerEvents
- type BytesFilter
- type BytesRejectedEvent
- type CachedApprover
- type CachedApprovers
- type CachedAttachment
- type CachedAttachments
- type CachedMarkerIndexBranchIDMapping
- func (c *CachedMarkerIndexBranchIDMapping) Consume(consumer func(markerIndexBranchIDMapping *MarkerIndexBranchIDMapping), ...) (consumed bool)
- func (c *CachedMarkerIndexBranchIDMapping) Retain() *CachedMarkerIndexBranchIDMapping
- func (c *CachedMarkerIndexBranchIDMapping) String() string
- func (c *CachedMarkerIndexBranchIDMapping) Unwrap() *MarkerIndexBranchIDMapping
- type CachedMessage
- type CachedMessageMetadata
- func (c *CachedMessageMetadata) Consume(consumer func(messageMetadata *MessageMetadata), forceRelease ...bool) (consumed bool)
- func (c *CachedMessageMetadata) ID() (messageID MessageID)
- func (c *CachedMessageMetadata) Retain() *CachedMessageMetadata
- func (c *CachedMessageMetadata) Unwrap() *MessageMetadata
- type CachedMissingMessage
- func (c *CachedMissingMessage) Consume(consumer func(missingMessage *MissingMessage), forceRelease ...bool) (consumed bool)
- func (c *CachedMissingMessage) ID() (id MessageID)
- func (c *CachedMissingMessage) Retain() *CachedMissingMessage
- func (c *CachedMissingMessage) String() string
- func (c *CachedMissingMessage) Unwrap() *MissingMessage
- type CachedOpinion
- type ConflictSet
- type Events
- type FCoB
- func (f *FCoB) CachedOpinion(transactionID ledgerstate.TransactionID) (cachedOpinion *CachedOpinion)
- func (f *FCoB) Evaluate(messageID MessageID)
- func (f *FCoB) Opinion(messageID MessageID) (opinion bool)
- func (f *FCoB) OpinionEssence(transactionID ledgerstate.TransactionID) (opinion OpinionEssence)
- func (f *FCoB) OpinionsEssence(conflictSet ledgerstate.TransactionIDs) (opinions []OpinionEssence)
- func (f *FCoB) ProcessVote(ev *vote.OpinionEvent)
- func (f *FCoB) Setup(payloadEvent *events.Event)
- func (f *FCoB) Shutdown()
- func (f *FCoB) Vote() *events.Event
- func (f *FCoB) VoteError() *events.Event
- type FCoBEvents
- type LedgerState
- func (l *LedgerState) BookTransaction(transaction *ledgerstate.Transaction, messageID MessageID) (targetBranch ledgerstate.BranchID, err error)
- func (l *LedgerState) BranchID(transactionID ledgerstate.TransactionID) (branchID ledgerstate.BranchID)
- func (l *LedgerState) BranchInclusionState(branchID ledgerstate.BranchID) (inclusionState ledgerstate.InclusionState)
- func (l *LedgerState) ConflictSet(transactionID ledgerstate.TransactionID) (conflictSet ledgerstate.TransactionIDs)
- func (l *LedgerState) InheritBranch(referencedBranchIDs ledgerstate.BranchIDs) (inheritedBranch ledgerstate.BranchID, err error)
- func (l *LedgerState) LoadSnapshot(...)
- func (l *LedgerState) Shutdown()
- func (l *LedgerState) TransactionConflicting(transactionID ledgerstate.TransactionID) bool
- func (l *LedgerState) TransactionInclusionState(transactionID ledgerstate.TransactionID) (ledgerstate.InclusionState, error)
- func (l *LedgerState) TransactionMetadata(transactionID ledgerstate.TransactionID) (cachedTransactionMetadata *ledgerstate.CachedTransactionMetadata)
- func (l *LedgerState) TransactionValid(transaction *ledgerstate.Transaction, messageID MessageID) (valid bool)
- type LevelOfKnowledge
- type MarkerBranchIDMappingManager
- type MarkerIndexBranchIDMapping
- func MarkerIndexBranchIDMappingFromBytes(bytes []byte) (markerIndexBranchIDMapping *MarkerIndexBranchIDMapping, consumedBytes int, ...)
- func MarkerIndexBranchIDMappingFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (markerIndexBranchIDMapping *MarkerIndexBranchIDMapping, err error)
- func NewMarkerIndexBranchIDMapping(sequenceID markers.SequenceID) (markerBranchMapping *MarkerIndexBranchIDMapping)
- func (m *MarkerIndexBranchIDMapping) BranchID(markerIndex markers.Index) (branchID ledgerstate.BranchID)
- func (m *MarkerIndexBranchIDMapping) Bytes() []byte
- func (m *MarkerIndexBranchIDMapping) ObjectStorageKey() []byte
- func (m *MarkerIndexBranchIDMapping) ObjectStorageValue() []byte
- func (m *MarkerIndexBranchIDMapping) SequenceID() markers.SequenceID
- func (m *MarkerIndexBranchIDMapping) SetBranchID(index markers.Index, branchID ledgerstate.BranchID)
- func (m *MarkerIndexBranchIDMapping) String() string
- func (m *MarkerIndexBranchIDMapping) Update(other objectstorage.StorableObject)
- type MarkersManager
- type Message
- func (m *Message) Bytes() []byte
- func (m *Message) ForEachParent(consumer func(parent Parent))
- func (m *Message) ForEachStrongParent(consumer func(parentMessageID MessageID))
- func (m *Message) ForEachWeakParent(consumer func(parentMessageID MessageID))
- func (m *Message) ID() (result MessageID)
- func (m *Message) IssuerPublicKey() ed25519.PublicKey
- func (m *Message) IssuingTime() time.Time
- func (m *Message) Nonce() uint64
- func (m *Message) ObjectStorageKey() []byte
- func (m *Message) ObjectStorageValue() []byte
- func (m *Message) Parents() (parents MessageIDs)
- func (m *Message) ParentsCount() uint8
- func (m *Message) Payload() payload.Payload
- func (m *Message) SequenceNumber() uint64
- func (m *Message) Signature() ed25519.Signature
- func (m *Message) String() string
- func (m *Message) StrongParents() MessageIDs
- func (m *Message) Update(objectstorage.StorableObject)
- func (m *Message) VerifySignature() bool
- func (m *Message) Version() uint8
- func (m *Message) WeakParents() MessageIDs
- type MessageExistsFunc
- type MessageFactory
- type MessageFactoryEvents
- type MessageFilter
- type MessageID
- type MessageIDs
- type MessageMetadata
- func (m *MessageMetadata) BranchID() ledgerstate.BranchID
- func (m *MessageMetadata) Bytes() []byte
- func (m *MessageMetadata) ID() MessageID
- func (m *MessageMetadata) IsBooked() (result bool)
- func (m *MessageMetadata) IsEligible() (result bool)
- func (m *MessageMetadata) IsInvalid() (result bool)
- func (m *MessageMetadata) IsSolid() (result bool)
- func (m *MessageMetadata) ObjectStorageKey() []byte
- func (m *MessageMetadata) ObjectStorageValue() []byte
- func (m *MessageMetadata) ReceivedTime() time.Time
- func (m *MessageMetadata) SetBooked(booked bool) (modified bool)
- func (m *MessageMetadata) SetBranchID(ID ledgerstate.BranchID) (modified bool)
- func (m *MessageMetadata) SetEligible(eligible bool) (modified bool)
- func (m *MessageMetadata) SetInvalid(invalid bool) (modified bool)
- func (m *MessageMetadata) SetSolid(solid bool) (modified bool)
- func (m *MessageMetadata) SetStructureDetails(structureDetails *markers.StructureDetails) (modified bool)
- func (m *MessageMetadata) SetTimestampOpinion(timestampOpinion TimestampOpinion) (modified bool)
- func (m *MessageMetadata) SolidificationTime() time.Time
- func (m *MessageMetadata) StructureDetails() *markers.StructureDetails
- func (m *MessageMetadata) TimestampOpinion() (timestampOpinion TimestampOpinion)
- func (m *MessageMetadata) Update(other objectstorage.StorableObject)
- type MessageParsedEvent
- type MessageRejectedEvent
- type MessageRequesterEvents
- type MessageSignatureFilter
- type MessageToSchedule
- type MissingMessage
- func (m *MissingMessage) Bytes() []byte
- func (m *MissingMessage) MessageID() MessageID
- func (m *MissingMessage) MissingSince() time.Time
- func (m *MissingMessage) ObjectStorageKey() []byte
- func (m *MissingMessage) ObjectStorageValue() (result []byte)
- func (m *MissingMessage) Update(other objectstorage.StorableObject)
- type OldTangle
- type Opinion
- func (o *Opinion) Bytes() []byte
- func (o *Opinion) LevelOfKnowledge() LevelOfKnowledge
- func (o *Opinion) Liked() bool
- func (o *Opinion) ObjectStorageKey() []byte
- func (o *Opinion) ObjectStorageValue() []byte
- func (o *Opinion) SetLevelOfKnowledge(lok LevelOfKnowledge)
- func (o *Opinion) SetLiked(l bool)
- func (o *Opinion) SetTimestamp(t time.Time)
- func (o *Opinion) String() string
- func (o *Opinion) Timestamp() time.Time
- func (o *Opinion) Update(other objectstorage.StorableObject)
- type OpinionEssence
- type OpinionFormedEvent
- type OpinionFormer
- type OpinionFormerEvents
- type OpinionProvider
- type OpinionVoterProvider
- type Option
- type Options
- type Parent
- type Parser
- type ParserEvents
- type PowFilter
- type RecentlySeenBytesFilter
- type Requester
- type RequesterOption
- type RequesterOptions
- type Scheduler
- type SchedulerEvents
- type SchedulerParentPriorityMap
- type SendRequestEvent
- type Solidifier
- type SolidifierEvents
- type Storage
- func (s *Storage) Approvers(messageID MessageID, optionalApproverType ...ApproverType) (cachedApprovers CachedApprovers)
- func (s *Storage) AttachmentMessageIDs(transactionID ledgerstate.TransactionID) (messageIDs MessageIDs)
- func (s *Storage) Attachments(transactionID ledgerstate.TransactionID) (cachedAttachments CachedAttachments)
- func (s *Storage) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64, ...)
- func (s *Storage) DeleteMessage(messageID MessageID)
- func (s *Storage) DeleteMissingMessage(messageID MessageID)
- func (s *Storage) MarkerIndexBranchIDMapping(sequenceID markers.SequenceID, ...) *CachedMarkerIndexBranchIDMapping
- func (s *Storage) Message(messageID MessageID) *CachedMessage
- func (s *Storage) MessageMetadata(messageID MessageID, computeIfAbsentCallback ...func() *MessageMetadata) *CachedMessageMetadata
- func (s *Storage) MissingMessages() (ids []MessageID)
- func (s *Storage) Prune() error
- func (s *Storage) RetrieveAllTips() (tips []MessageID)
- func (s *Storage) Setup()
- func (s *Storage) Shutdown()
- func (s *Storage) StoreAttachment(transactionID ledgerstate.TransactionID, messageID MessageID) (cachedAttachment *CachedAttachment, stored bool)
- func (s *Storage) StoreMessage(message *Message)
- func (s *Storage) StoreMissingMessage(missingMessage *MissingMessage) (cachedMissingMessage *CachedMissingMessage, stored bool)
- type StorageEvents
- type Tangle
- type TimeMessageQueue
- type TimestampLikedByDefault
- type TimestampLikedByDefaultEvents
- type TimestampOpinion
- func TimestampOpinionFromBytes(bytes []byte) (timestampOpinion TimestampOpinion, consumedBytes int, err error)
- func TimestampOpinionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result TimestampOpinion, err error)
- func TimestampQuality(target, current time.Time) (timestampOpinion TimestampOpinion)
- type TipManager
- type TipManagerEvents
- type TipSelector
- type TipSelectorFunc
- type TransactionFilter
- type Utils
- func (u *Utils) ApprovingMessageIDs(messageID MessageID, optionalApproverType ...ApproverType) (approvingMessageIDs MessageIDs)
- func (u *Utils) ComputeIfTransaction(messageID MessageID, compute func(ledgerstate.TransactionID)) (computed bool)
- func (u *Utils) MessageApprovedBy(approvedMessageID MessageID, approvingMessageID MessageID) (approved bool)
- func (u *Utils) MessageStronglyApprovedBy(approvedMessageID MessageID, approvingMessageID MessageID) (stronglyApproved bool)
- func (u *Utils) WalkMessage(callback func(message *Message, walker *walker.Walker), entryPoints MessageIDs, ...)
- func (u *Utils) WalkMessageAndMetadata(...)
- func (u *Utils) WalkMessageID(callback func(messageID MessageID, walker *walker.Walker), ...)
- func (u *Utils) WalkMessageMetadata(callback func(messageMetadata *MessageMetadata, walker *walker.Walker), ...)
- type Worker
- type WorkerFunc
Constants ¶
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 )
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 // PrefixFCoB defines the storage prefix for FCoB. PrefixFCoB // DBSequenceNumber defines the db sequence number. DBSequenceNumber = "seq" )
const ApproverTypeLength = 1
ApproverTypeLength contains the amount of bytes that a marshaled version of the ApproverType contains.
const AttachmentLength = ledgerstate.TransactionIDLength + MessageIDLength
AttachmentLength holds the length of a marshaled Attachment in bytes.
const ( // DefaultRetryInterval defines the Default Retry Interval of the message requester. DefaultRetryInterval = 10 * time.Second )
const ( // MaxReattachmentTimeMin defines the max reattachment time. MaxReattachmentTimeMin = 10 * time.Minute )
const ( // TimestampOpinionLength defines the length of a TimestampOpinion object. // (1 byte of opinion, 1 byte of LoK). TimestampOpinionLength = 2 )
Variables ¶
var ( // LikedThreshold is the first time thresshold of FCoB. LikedThreshold = 5 * time.Second // LocallyFinalizedThreshold is the second time thresshold of FCoB. LocallyFinalizedThreshold = 10 * time.Second )
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") )
var ( // TimestampWindow defines the time window for assessing the timestamp quality. TimestampWindow time.Duration // GratuitousNetworkDelay defines the time after which we assume all messages are delivered. GratuitousNetworkDelay time.Duration )
var EmptyMessageID = MessageID{}
EmptyMessageID is an empty id.
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 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 MessageFromObjectStorage ¶
func MessageFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
MessageFromObjectStorage restores a Message from the ObjectStorage.
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 OpinionFromObjectStorage ¶ added in v0.3.6
func OpinionFromObjectStorage(key []byte, data []byte) (result objectstorage.StorableObject, err error)
OpinionFromObjectStorage restores an Opinion from the ObjectStorage.
Types ¶
type Approver ¶
type Approver struct { objectstorage.StorableObjectFlags // contains filtered or unexported fields }
Approver is an approver of a given referenced message.
func ApproverFromBytes ¶
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 ¶
ApproverMessageID returns the ID of the message which referenced the given approved message.
func (*Approver) ObjectStorageKey ¶
ObjectStorageKey marshals the keys of the stored approver into a byte array. This includes the referencedMessageID and the approverMessageID.
func (*Approver) ObjectStorageValue ¶
ObjectStorageValue returns the value of the stored approver object.
func (*Approver) ReferencedMessageID ¶
ReferencedMessageID returns the ID of the message which is referenced by 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 MarkerBranchIDMappingManager *MarkerBranchIDMappingManager // 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.
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 }
BookerEvents represents events happening in the Booker.
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 ¶
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 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 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
func (c *CachedMarkerIndexBranchIDMapping) Retain() *CachedMarkerIndexBranchIDMapping
Retain marks the CachedObject to still be in use by the program.
func (*CachedMarkerIndexBranchIDMapping) String ¶ added in v0.3.6
func (c *CachedMarkerIndexBranchIDMapping) String() string
String returns a human readable version of the CachedMarkerIndexBranchIDMapping.
func (*CachedMarkerIndexBranchIDMapping) Unwrap ¶ added in v0.3.6
func (c *CachedMarkerIndexBranchIDMapping) Unwrap() *MarkerIndexBranchIDMapping
Unwrap is the type-casted equivalent of Get. It returns nil if the object 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 ¶
func (c *CachedMessageMetadata) Retain() *CachedMessageMetadata
Retain registers a new consumer for the cached message metadata.
func (*CachedMessageMetadata) Unwrap ¶
func (c *CachedMessageMetadata) Unwrap() *MessageMetadata
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
func (c *CachedMissingMessage) Retain() *CachedMissingMessage
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 CachedOpinion ¶ added in v0.3.6
type CachedOpinion struct {
objectstorage.CachedObject
}
CachedOpinion is a wrapper for the generic CachedObject returned by the object storage that overrides the accessor methods with a type-casted one.
func (*CachedOpinion) Consume ¶ added in v0.3.6
func (c *CachedOpinion) Consume(consumer func(opinion *Opinion), 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 (*CachedOpinion) Retain ¶ added in v0.3.6
func (c *CachedOpinion) Retain() *CachedOpinion
Retain marks the CachedObject to still be in use by the program.
func (*CachedOpinion) String ¶ added in v0.3.6
func (c *CachedOpinion) String() string
String returns a human readable version of the CachedOpinion.
func (*CachedOpinion) Unwrap ¶ added in v0.3.6
func (c *CachedOpinion) Unwrap() *Opinion
Unwrap is the type-casted equivalent of Get. It returns nil if the object does not exist.
type ConflictSet ¶ added in v0.3.6
type ConflictSet []OpinionEssence
ConflictSet is a list of Opinion.
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 FCoB ¶ added in v0.3.6
type FCoB struct { Events *FCoBEvents // contains filtered or unexported fields }
FCoB is the component implementing the Fast Consensus of Barcelona protocol.
func (*FCoB) CachedOpinion ¶ added in v0.3.6
func (f *FCoB) CachedOpinion(transactionID ledgerstate.TransactionID) (cachedOpinion *CachedOpinion)
CachedOpinion returns the CachedOpinion of the given TransactionID.
func (*FCoB) OpinionEssence ¶ added in v0.3.6
func (f *FCoB) OpinionEssence(transactionID ledgerstate.TransactionID) (opinion OpinionEssence)
OpinionEssence returns the OpinionEssence (i.e., a copy of the triple{timestamp, liked, levelOfKnowledge}) of given transactionID.
func (*FCoB) OpinionsEssence ¶ added in v0.3.6
func (f *FCoB) OpinionsEssence(conflictSet ledgerstate.TransactionIDs) (opinions []OpinionEssence)
OpinionsEssence returns a list of OpinionEssence (i.e., a copy of the triple{timestamp, liked, levelOfKnowledge}) of given conflicSet.
func (*FCoB) ProcessVote ¶ added in v0.3.6
func (f *FCoB) ProcessVote(ev *vote.OpinionEvent)
ProcessVote allows an external voter to hand in the results of the voting process.
func (*FCoB) Setup ¶ added in v0.3.6
Setup sets up the behavior of the component by making it attach to the relevant events of the other components.
func (*FCoB) Shutdown ¶ added in v0.3.6
func (f *FCoB) Shutdown()
Shutdown shuts down FCoB and persists its state.
type FCoBEvents ¶ added in v0.3.6
type FCoBEvents struct { // Fired when an opinion of a payload is formed. PayloadOpinionFormed *events.Event // Error gets called when FCOB faces an error. Error *events.Event // Vote gets called when FCOB needs to vote. Vote *events.Event }
FCoBEvents defines all the events related to the Fast Consensus of Barcelona protocol.
type LedgerState ¶ added in v0.3.6
type LedgerState struct {
// 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) 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) 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 map[ledgerstate.TransactionID]map[ledgerstate.Address]*ledgerstate.ColoredBalances)
LoadSnapshot creates a set of outputs in the UTXO-DAG, that are forming the genesis for future transactions.
func (*LedgerState) Shutdown ¶ added in v0.3.6
func (l *LedgerState) Shutdown()
Shutdown shuts down the LedgerState and persists its state.
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) (valid bool)
TransactionValid performs some fast checks of the Transaction and triggers a MessageInvalid event if the checks do not pass.
type LevelOfKnowledge ¶ added in v0.3.6
type LevelOfKnowledge = uint8
LevelOfKnowledge defines the Level Of Knowledge type.
const ( // Pending implies that the opinion is not formed yet. Pending LevelOfKnowledge = iota // One implies that voting is required. One // Two implies that we have locally finalized our opinion but we can still reply to eventual queries. Two // Three implies that we have locally finalized our opinion and we do not reply to eventual queries. Three )
The different levels of knowledge.
type MarkerBranchIDMappingManager ¶ added in v0.3.6
type MarkerBranchIDMappingManager struct {
// contains filtered or unexported fields
}
MarkerBranchIDMappingManager is a data structure that enables the mapping of Markers to BranchIDs with binary search efficiency (O(log(n)) where n is the amount of Markers that have a unique BranchID value).
func NewMarkerBranchIDMappingManager ¶ added in v0.3.6
func NewMarkerBranchIDMappingManager(tangle *Tangle) (markerBranchIDMappingManager *MarkerBranchIDMappingManager)
NewMarkerBranchIDMappingManager is the constructor for the MarkerBranchIDMappingManager.
func (*MarkerBranchIDMappingManager) BranchID ¶ added in v0.3.6
func (m *MarkerBranchIDMappingManager) BranchID(marker *markers.Marker) (branchID ledgerstate.BranchID)
BranchID returns the BranchID that is associated with the given Marker.
func (*MarkerBranchIDMappingManager) SetBranchID ¶ added in v0.3.6
func (m *MarkerBranchIDMappingManager) SetBranchID(marker *markers.Marker, branchID ledgerstate.BranchID)
SetBranchID associates a BranchID with the given Marker.
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) 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
func (m *MarkerIndexBranchIDMapping) SequenceID() markers.SequenceID
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
func (m *MarkerIndexBranchIDMapping) Update(other objectstorage.StorableObject)
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
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) InheritStructureDetails ¶ added in v0.3.6
func (m *MarkersManager) InheritStructureDetails(message *Message, branchID ledgerstate.BranchID) (structureDetails *markers.StructureDetails)
InheritStructureDetails returns the structure Details of a Message that are derived from the StructureDetails of its strong parents.
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 ¶
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) ForEachParent ¶ added in v0.3.1
ForEachParent executes a consumer func for each parent.
func (*Message) ForEachStrongParent ¶ added in v0.3.1
ForEachStrongParent executes a consumer func for each strong parent.
func (*Message) ForEachWeakParent ¶ added in v0.3.1
ForEachWeakParent executes a consumer func for each weak parent.
func (*Message) ID ¶
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) IssuerPublicKey ¶
IssuerPublicKey returns the public key of the message issuer.
func (*Message) IssuingTime ¶
IssuingTime returns the time when this message was created.
func (*Message) ObjectStorageKey ¶
ObjectStorageKey returns the key of the stored message object. This returns the bytes of the message ID.
func (*Message) ObjectStorageValue ¶
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
ParentsCount returns the total parents count of this message.
func (*Message) SequenceNumber ¶
SequenceNumber returns the sequence number of this message.
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 ¶
func (m *Message) Update(objectstorage.StorableObject)
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 ¶
VerifySignature verifies the signature of the message.
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 ¶
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 ¶
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) 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)) }
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 ¶
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 ¶
NewMessageID creates a new message id.
func (*MessageID) MarshalBinary ¶
MarshalBinary marshals the MessageID into bytes.
func (*MessageID) UnmarshalBinary ¶
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 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) 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) 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) 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) 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(ID 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) 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) 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) SetTimestampOpinion ¶ added in v0.3.6
func (m *MessageMetadata) SetTimestampOpinion(timestampOpinion TimestampOpinion) (modified bool)
SetTimestampOpinion sets the timestampOpinion flag. It returns true if the timestampOpinion flag is modified. False otherwise.
func (*MessageMetadata) SolidificationTime ¶
func (m *MessageMetadata) SolidificationTime() time.Time
SolidificationTime returns the time when the message was marked to be solid.
func (*MessageMetadata) StructureDetails ¶ added in v0.3.6
func (m *MessageMetadata) StructureDetails() *markers.StructureDetails
StructureDetails returns the structureDetails of the message.
func (*MessageMetadata) TimestampOpinion ¶ added in v0.3.6
func (m *MessageMetadata) TimestampOpinion() (timestampOpinion TimestampOpinion)
TimestampOpinion returns the timestampOpinion of the given message metadata.
func (*MessageMetadata) Update ¶
func (m *MessageMetadata) Update(other objectstorage.StorableObject)
Update updates the message metadata. This should never happen and will panic if attempted.
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 ¶
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) 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.
type MessageToSchedule ¶ added in v0.3.6
type MessageToSchedule struct { ID MessageID // contains filtered or unexported fields }
MessageToSchedule contains the relevant information to schedule a message.
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 OldTangle ¶ added in v0.3.6
OldTangle represents the base layer of messages.
func (*OldTangle) CheckParentsEligibility ¶ added in v0.3.6
func (t *OldTangle) CheckParentsEligibility(cachedMessage *CachedMessage, cachedMsgMetadata *CachedMessageMetadata)
CheckParentsEligibility checks if the parents are eligible, then set the eligible flag of the message. TODO: Eligibility related functions will be moved elsewhere.
type Opinion ¶ added in v0.3.6
type Opinion struct { objectstorage.StorableObjectFlags // the essence associated to this opinion. OpinionEssence // contains filtered or unexported fields }
Opinion defines the FCoB opinion about a transaction.
func OpinionFromMarshalUtil ¶ added in v0.3.6
func OpinionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result *Opinion, err error)
OpinionFromMarshalUtil parses an opinion from the given marshal util.
func (*Opinion) LevelOfKnowledge ¶ added in v0.3.6
func (o *Opinion) LevelOfKnowledge() LevelOfKnowledge
LevelOfKnowledge returns the opinion's LevelOfKnowledge.
func (*Opinion) ObjectStorageKey ¶ added in v0.3.6
ObjectStorageKey returns the key that is used to store the object in the database. It is required to match the StorableObject interface.
func (*Opinion) ObjectStorageValue ¶ added in v0.3.6
ObjectStorageValue marshals the Opinion into a sequence of bytes. The ID is not serialized here as it is only used as a key in the ObjectStorage.
func (*Opinion) SetLevelOfKnowledge ¶ added in v0.3.6
func (o *Opinion) SetLevelOfKnowledge(lok LevelOfKnowledge)
SetLevelOfKnowledge sets the opinion's LevelOfKnowledge.
func (*Opinion) SetTimestamp ¶ added in v0.3.6
SetTimestamp sets the opinion's timestamp.
func (*Opinion) Update ¶ added in v0.3.6
func (o *Opinion) Update(other objectstorage.StorableObject)
Update is disabled and panics if it ever gets called - it is required to match the StorableObject interface.
type OpinionEssence ¶ added in v0.3.6
type OpinionEssence struct {
// contains filtered or unexported fields
}
OpinionEssence contains the essence of an opinion (timestamp, liked, level of knowledge).
type OpinionFormedEvent ¶ added in v0.3.6
type OpinionFormedEvent struct { // The messageID of the message containing the payload. MessageID MessageID // The opinion of the payload. Opinion bool }
OpinionFormedEvent holds data about a Payload/MessageOpinionFormed event.
type OpinionFormer ¶ added in v0.3.6
type OpinionFormer struct { Events OpinionFormerEvents TimestampOpinionProvider OpinionProvider // contains filtered or unexported fields }
OpinionFormer is the component in charge of forming opinion about timestamps and payloads.
func NewOpinionFormer ¶ added in v0.3.6
func NewOpinionFormer(tangle *Tangle, payloadOpinionVoterProvider OpinionVoterProvider, timestampOpinionProvider OpinionProvider) (opinionFormer *OpinionFormer)
NewOpinionFormer returns a new OpinionFormer.
func (*OpinionFormer) MessageEligible ¶ added in v0.3.6
func (o *OpinionFormer) MessageEligible(messageID MessageID) (eligible bool)
MessageEligible returns whether the given messageID is marked as aligible.
func (*OpinionFormer) PayloadLiked ¶ added in v0.3.6
func (o *OpinionFormer) PayloadLiked(messageID MessageID) (liked bool)
PayloadLiked returns the opinion of the given MessageID.
func (*OpinionFormer) Setup ¶ added in v0.3.6
func (o *OpinionFormer) Setup()
Setup sets up the behavior of the component by making it attach to the relevant events of the other components.
func (*OpinionFormer) Shutdown ¶ added in v0.3.6
func (o *OpinionFormer) Shutdown()
Shutdown shuts down the component and persists its state.
type OpinionFormerEvents ¶ added in v0.3.6
type OpinionFormerEvents struct { // Fired when an opinion of a payload is formed. PayloadOpinionFormed *events.Event // Fired when an opinion of a timestamp is formed. TimestampOpinionFormed *events.Event // Fired when an opinion of a message is formed. MessageOpinionFormed *events.Event }
OpinionFormerEvents defines all the events related to the opinion manager.
type OpinionProvider ¶ added in v0.3.6
type OpinionProvider interface { // Evaluate evaluates the opinion of the given messageID (payload / timestamp). Evaluate(MessageID) // Opinion returns the opinion of the given messageID (payload / timestamp). Opinion(MessageID) bool // Setup allows to wire the communication between the opinionProvider and the opinionFormer. Setup(*events.Event) // Shutdown shuts down the OpinionProvider and persists its state. Shutdown() }
OpinionProvider is the interface to describe the functionalities of an opinion provider.
type OpinionVoterProvider ¶ added in v0.3.6
type OpinionVoterProvider interface { // OpinionProvider is the interface to describe the functionalities of an opinion provider. OpinionProvider // Vote trigger a voting request. Vote() *events.Event // VoteError notify an error coming from the result of voting. VoteError() *events.Event // ProcessVote allows an external voter to hand in the results of the voting process. ProcessVote(*vote.OpinionEvent) }
OpinionVoterProvider is the interface to describe the functionalities of an opinion and voter provider.
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 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 Store ¶ added in v0.3.6
Store is an Option for the Tangle that allows to specify which storage layer is supposed to be used to persist data.
func WithoutOpinionFormer ¶ added in v0.3.6
WithoutOpinionFormer an Option for the Tangle that allows to disable the OpinionFormer component.
type Options ¶
type Options struct { Store kvstore.KVStore Identity *identity.LocalIdentity WithoutOpinionFormer bool }
Options is a container for all configurable parameters of the Tangle.
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.
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 ¶
NewPowFilter creates a new PoW bytes filter.
func (*PowFilter) Filter ¶
Filter checks whether the given bytes pass the PoW validation and calls the corresponding callback.
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.
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
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
StartRequest initiates a regular triggering of the StartRequest event until it has been stopped using StopRequest.
func (*Requester) StopRequest ¶ added in v0.3.6
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 implements the scheduler.
func NewScheduler ¶ added in v0.3.6
NewScheduler returns a new Scheduler.
type SchedulerEvents ¶ added in v0.3.6
type SchedulerEvents struct { // MessageScheduled is triggered when a message is ready to be scheduled. MessageScheduled *events.Event }
SchedulerEvents represents events happening in the Scheduler.
type SchedulerParentPriorityMap ¶ added in v0.3.6
type SchedulerParentPriorityMap map[MessageID][]*MessageToSchedule
SchedulerParentPriorityMap maps parentIDs with their children messages.
type SendRequestEvent ¶
type SendRequestEvent struct {
ID MessageID
}
SendRequestEvent represents the parameters of sendRequestEventHandler
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 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
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) 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) DeleteMessage ¶ added in v0.3.6
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
DeleteMissingMessage deletes a message from the missingMessageStorage.
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) 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
MissingMessages return the ids of messages in missingMessageStorage
func (*Storage) Prune ¶ added in v0.3.6
Prune resets the database and deletes all objects (good for testing or "node resets").
func (*Storage) RetrieveAllTips ¶ added in v0.3.6
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) 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) 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) StoreMessage ¶ added in v0.3.6
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 Tangle ¶
type Tangle struct { Parser *Parser Storage *Storage Solidifier *Solidifier Scheduler *Scheduler Booker *Booker TipManager *TipManager Requester *Requester MessageFactory *MessageFactory LedgerState *LedgerState Utils *Utils Options *Options Events *Events OpinionFormer *OpinionFormer PayloadOpinionProvider OpinionVoterProvider TimestampOpinionProvider OpinionProvider // contains filtered or unexported fields }
Tangle is the central data structure of the IOTA protocol.
func (*Tangle) ProcessGossipMessage ¶ added in v0.3.6
ProcessGossipMessage is used to feed new Messages from the gossip layer into the Tangle.
func (*Tangle) Prune ¶
Prune resets the database and deletes all stored objects (good for testing or "node resets").
type TimeMessageQueue ¶ added in v0.3.6
type TimeMessageQueue struct { C chan *MessageToSchedule // contains filtered or unexported fields }
TimeMessageQueue is a time-based ordered queue.
func NewTimeMessageQueue ¶ added in v0.3.6
func NewTimeMessageQueue(capacity int) *TimeMessageQueue
NewTimeMessageQueue returns a new TimeMessageQueue.
func (*TimeMessageQueue) Add ¶ added in v0.3.6
func (t *TimeMessageQueue) Add(message *MessageToSchedule)
Add adds a message to the TimeMessageQueue.
func (*TimeMessageQueue) Pop ¶ added in v0.3.6
func (t *TimeMessageQueue) Pop() (message *MessageToSchedule)
Pop returns the first message to schedule.
func (*TimeMessageQueue) Start ¶ added in v0.3.6
func (t *TimeMessageQueue) Start()
Start starts the TimeMessageQueue.
func (*TimeMessageQueue) Stop ¶ added in v0.3.6
func (t *TimeMessageQueue) Stop()
Stop stops the TimeMessageQueue.
type TimestampLikedByDefault ¶ added in v0.3.6
type TimestampLikedByDefault struct { Events *TimestampLikedByDefaultEvents // contains filtered or unexported fields }
TimestampLikedByDefault is the opinion provider that likes all the timestamps.
func NewTimestampLikedByDefault ¶ added in v0.3.6
func NewTimestampLikedByDefault(tangle *Tangle) (timestampByDefault *TimestampLikedByDefault)
NewTimestampLikedByDefault returns a new instance of the TimestampLikedByDefault.
func (*TimestampLikedByDefault) Evaluate ¶ added in v0.3.6
func (t *TimestampLikedByDefault) Evaluate(messageID MessageID)
Evaluate evaluates the opinion of the given messageID.
func (*TimestampLikedByDefault) Opinion ¶ added in v0.3.6
func (t *TimestampLikedByDefault) Opinion(messageID MessageID) (opinion bool)
Opinion returns the liked status of a given messageID.
func (*TimestampLikedByDefault) Setup ¶ added in v0.3.6
func (t *TimestampLikedByDefault) Setup(timestampEvent *events.Event)
Setup sets up the behavior of the component by making it attach to the relevant events of the other components. It is required to satisfy the OpinionProvider interface.
func (*TimestampLikedByDefault) Shutdown ¶ added in v0.3.6
func (t *TimestampLikedByDefault) Shutdown()
Shutdown shuts down component and persists its state. It is required to satisfy the OpinionProvider interface.
type TimestampLikedByDefaultEvents ¶ added in v0.3.6
type TimestampLikedByDefaultEvents struct { // Fired when an opinion of a timestamp is formed. TimestampOpinionFormed *events.Event }
TimestampLikedByDefaultEvents defines all the events related to the TimestampLikedByDefault opinion provider.
type TimestampOpinion ¶ added in v0.3.6
type TimestampOpinion struct { Value opinion.Opinion LoK LevelOfKnowledge }
TimestampOpinion contains the value of a timestamp opinion as well as its level of knowledge.
func TimestampOpinionFromBytes ¶ added in v0.3.6
func TimestampOpinionFromBytes(bytes []byte) (timestampOpinion TimestampOpinion, consumedBytes int, err error)
TimestampOpinionFromBytes parses a TimestampOpinion from a byte slice.
func TimestampOpinionFromMarshalUtil ¶ added in v0.3.6
func TimestampOpinionFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (result TimestampOpinion, err error)
TimestampOpinionFromMarshalUtil is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.
func TimestampQuality ¶ added in v0.3.6
func TimestampQuality(target, current time.Time) (timestampOpinion TimestampOpinion)
TimestampQuality returns the timestamp opinion based on the given times (e.g., arrival and current).
func (TimestampOpinion) Bytes ¶ added in v0.3.6
func (t TimestampOpinion) Bytes() (bytes []byte)
Bytes returns the timestamp statement encoded as bytes.
func (TimestampOpinion) Equal ¶ added in v0.3.6
func (t TimestampOpinion) Equal(x TimestampOpinion) bool
Equal returns true if the given timestampOpinion is equal to the given x.
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(msg *Message)
AddTip adds the given message as a tip.
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) TipCount ¶ added in v0.3.6
func (t *TipManager) TipCount() int
TipCount the amount of current tips.
func (*TipManager) Tips ¶ added in v0.3.6
func (t *TipManager) Tips(count int) (parents []MessageID)
Tips returns count number of tips, maximum MaxParentsCount.
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 ¶
A TipSelector selects two tips, parent2 and parent1, for a new message to attach to.
type TipSelectorFunc ¶
The TipSelectorFunc type is an adapter to allow the use of ordinary functions as tip selectors.
func (TipSelectorFunc) Tips ¶
func (f TipSelectorFunc) Tips(count int) (parents []MessageID)
Tips calls f().
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) 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.
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 (*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) MessageStronglyApprovedBy ¶ added in v0.3.6
func (u *Utils) MessageStronglyApprovedBy(approvedMessageID MessageID, approvingMessageID MessageID) (stronglyApproved bool)
MessageStronglyApprovedBy checks if the Message given by approvedMessageID is directly or indirectly approved by the Message given by approvingMessageID (ignoring weak parents as a potential last reference).
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.