Documentation
¶
Index ¶
- Constants
- func ApproverFromStorageKey(key []byte, optionalTargetObject ...*Approver) (result objectstorage.StorableObject, consumedBytes int, err error)
- func MessageMetadataFromStorageKey(key []byte) (result objectstorage.StorableObject, consumedBytes int, err error)
- func MissingMessageFromStorageKey(key []byte, optionalTargetObject ...*MissingMessage) (result objectstorage.StorableObject, consumedBytes int, err error)
- type Approver
- func ApproverFromBytes(bytes []byte, optionalTargetObject ...*Approver) (result *Approver, consumedBytes int, err error)
- func NewApprover(referencedMessageID message.ID, approverMessageID message.ID) *Approver
- func ParseApprover(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Approver) (result *Approver, err error)
- func (approver *Approver) ApproverMessageID() message.ID
- func (approver *Approver) Bytes() []byte
- func (approver *Approver) ObjectStorageKey() []byte
- func (approver *Approver) ObjectStorageValue() (result []byte)
- func (approver *Approver) ReferencedMessageID() message.ID
- func (approver *Approver) String() string
- func (approver *Approver) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
- func (approver *Approver) Update(other objectstorage.StorableObject)
- type CachedApprover
- type CachedApprovers
- type CachedMessageMetadata
- type Events
- type MessageMetadata
- func (messageMetadata *MessageMetadata) IsSolid() (result bool)
- func (messageMetadata *MessageMetadata) ObjectStorageKey() []byte
- func (messageMetadata *MessageMetadata) ObjectStorageValue() []byte
- func (messageMetadata *MessageMetadata) ReceivedTime() time.Time
- func (messageMetadata *MessageMetadata) SetSolid(solid bool) (modified bool)
- func (messageMetadata *MessageMetadata) SolidificationTime() time.Time
- func (messageMetadata *MessageMetadata) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
- func (messageMetadata *MessageMetadata) Update(other objectstorage.StorableObject)
- type MissingMessage
- func (missingMessage *MissingMessage) MessageID() message.ID
- func (missingMessage *MissingMessage) MissingSince() time.Time
- func (missingMessage *MissingMessage) ObjectStorageKey() []byte
- func (missingMessage *MissingMessage) ObjectStorageValue() (result []byte)
- func (missingMessage *MissingMessage) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
- func (missingMessage *MissingMessage) Update(other objectstorage.StorableObject)
- type Tangle
- func (tangle *Tangle) Approvers(messageID message.ID) CachedApprovers
- func (tangle *Tangle) AttachMessage(msg *message.Message)
- func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64, ...)
- func (tangle *Tangle) DeleteMessage(messageID message.ID)
- func (tangle *Tangle) DeleteMissingMessage(messageID message.ID)
- func (tangle *Tangle) Message(messageID message.ID) *message.CachedMessage
- func (tangle *Tangle) MessageMetadata(messageID message.ID) *CachedMessageMetadata
- func (tangle *Tangle) MissingMessages() (ids []message.ID)
- func (tangle *Tangle) Prune() error
- func (tangle *Tangle) RetrieveAllTips() (tips []message.ID)
- func (tangle *Tangle) Shutdown() *Tangle
- func (tangle *Tangle) SolidifierWorkerPoolStatus() (name string, load int)
- func (tangle *Tangle) StoreMessageWorkerPoolStatus() (name string, load int)
Constants ¶
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 )
Variables ¶
This section is empty.
Functions ¶
func ApproverFromStorageKey ¶
func ApproverFromStorageKey(key []byte, optionalTargetObject ...*Approver) (result objectstorage.StorableObject, consumedBytes int, err error)
ApproverFromStorageKey returns an approver for the given key.
func MessageMetadataFromStorageKey ¶
func MessageMetadataFromStorageKey(key []byte) (result objectstorage.StorableObject, consumedBytes int, err error)
MessageMetadataFromStorageKey unmarshals the stored bytes into a MessageMetadata.
func MissingMessageFromStorageKey ¶
func MissingMessageFromStorageKey(key []byte, optionalTargetObject ...*MissingMessage) (result objectstorage.StorableObject, consumedBytes int, err error)
MissingMessageFromStorageKey unmarshals the stored key into a desirable target specified by 0 or 1 optional argument. The default target is MissingMessage. It unmarshals into the target specified or panics if more than 1 target is specified.
Types ¶
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, optionalTargetObject ...*Approver) (result *Approver, consumedBytes int, err error)
ApproverFromBytes parses the given bytes into an approver.
func NewApprover ¶
NewApprover creates a new approver relation to the given approved/referenced message.
func ParseApprover ¶
func ParseApprover(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Approver) (result *Approver, err error)
ParseApprover parses a new approver from the given marshal util.
func (*Approver) ApproverMessageID ¶ added in v0.2.3
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 ¶ added in v0.2.3
ReferencedMessageID returns the ID of the message which is referenced by the approver.
func (*Approver) UnmarshalObjectStorageValue ¶
UnmarshalObjectStorageValue unmarshals the stored bytes into an approver.
func (*Approver) Update ¶
func (approver *Approver) Update(other objectstorage.StorableObject)
Update updates the approver. This should should never happen and will panic if attempted.
type CachedApprover ¶
type CachedApprover struct {
objectstorage.CachedObject
}
CachedApprover is a wrapper for a stored cached object representing an approver.
func (*CachedApprover) Consume ¶
func (cachedApprover *CachedApprover) Consume(consumer func(approver *Approver)) (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 (cachedApprover *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 (cachedApprovers CachedApprovers) Consume(consumer func(approver *Approver)) (consumed bool)
Consume calls *CachedApprover.Consume on element in the list.
type CachedMessageMetadata ¶
type CachedMessageMetadata struct {
objectstorage.CachedObject
}
CachedMessageMetadata is a wrapper for stored cached object that represents a message metadata.
func (*CachedMessageMetadata) Retain ¶
func (cachedMessageMetadata *CachedMessageMetadata) Retain() *CachedMessageMetadata
Retain registers a new consumer for the cached message metadata.
func (*CachedMessageMetadata) Unwrap ¶
func (cachedMessageMetadata *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 Events ¶
type Events struct { // Fired when a message has been attached. MessageAttached *events.Event // Fired when a message has been solid, i.e. its past cone // is known and in the database. MessageSolid *events.Event // Fired when a message which was previously marked as missing was received. MissingMessageReceived *events.Event // Fired when a message is missing which is needed to solidify a given approver message. MessageMissing *events.Event // Fired when a message was missing for too long and is // therefore considered to be unsolidifiable. MessageUnsolidifiable *events.Event // Fired when a message was removed from storage. MessageRemoved *events.Event }
Events represents events happening on the base layer Tangle.
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 NewMessageMetadata ¶
func NewMessageMetadata(messageID message.ID) *MessageMetadata
NewMessageMetadata creates a new MessageMetadata from the specified messageID.
func ParseMessageMetadata ¶
func ParseMessageMetadata(marshalUtil *marshalutil.MarshalUtil) (result *MessageMetadata, err error)
ParseMessageMetadata parses the marshalUtil into a MessageMetadata. If it successfully parses the marshalUtil, it delegates to MessageMetadataFromStorageKey. Else, delegates to UnmarshalObjectStorageValue.
func (*MessageMetadata) IsSolid ¶
func (messageMetadata *MessageMetadata) IsSolid() (result bool)
IsSolid returns true if the message represented by this metadata is solid. False otherwise.
func (*MessageMetadata) ObjectStorageKey ¶
func (messageMetadata *MessageMetadata) ObjectStorageKey() []byte
ObjectStorageKey returns the key of the stored message metadata object. This returns the bytes of the messageID.
func (*MessageMetadata) ObjectStorageValue ¶
func (messageMetadata *MessageMetadata) ObjectStorageValue() []byte
ObjectStorageValue returns the value of the stored message metadata object. This includes the receivedTime, solidificationTime and solid status.
func (*MessageMetadata) ReceivedTime ¶ added in v0.2.2
func (messageMetadata *MessageMetadata) ReceivedTime() time.Time
ReceivedTime returns the time when the message was received.
func (*MessageMetadata) SetSolid ¶
func (messageMetadata *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) SolidificationTime ¶
func (messageMetadata *MessageMetadata) SolidificationTime() time.Time
SolidificationTime returns the time when the message was marked to be solid.
func (*MessageMetadata) UnmarshalObjectStorageValue ¶
func (messageMetadata *MessageMetadata) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
UnmarshalObjectStorageValue unmarshals the stored bytes into a messageMetadata.
func (*MessageMetadata) Update ¶
func (messageMetadata *MessageMetadata) Update(other objectstorage.StorableObject)
Update updates the message metadata. This should never happen and will panic if attempted.
type MissingMessage ¶
type MissingMessage struct { objectstorage.StorableObjectFlags // contains filtered or unexported fields }
MissingMessage represents a missing message.
func NewMissingMessage ¶
func NewMissingMessage(messageID message.ID) *MissingMessage
NewMissingMessage creates new missing message with the specified messageID.
func (*MissingMessage) MessageID ¶ added in v0.2.3
func (missingMessage *MissingMessage) MessageID() message.ID
MessageID returns the id of the message.
func (*MissingMessage) MissingSince ¶
func (missingMessage *MissingMessage) MissingSince() time.Time
MissingSince returns the time since when this message is missing.
func (*MissingMessage) ObjectStorageKey ¶
func (missingMessage *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 (missingMessage *MissingMessage) ObjectStorageValue() (result []byte)
ObjectStorageValue returns the value of the stored missing message.
func (*MissingMessage) UnmarshalObjectStorageValue ¶
func (missingMessage *MissingMessage) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
UnmarshalObjectStorageValue unmarshals the stored bytes into a missing message.
func (*MissingMessage) Update ¶
func (missingMessage *MissingMessage) Update(other objectstorage.StorableObject)
Update update the missing message. It should never happen and will panic if called.
type Tangle ¶
type Tangle struct { Events Events // contains filtered or unexported fields }
Tangle represents the base layer of messages.
func (*Tangle) Approvers ¶
func (tangle *Tangle) Approvers(messageID message.ID) CachedApprovers
Approvers retrieves the approvers of a message from the tangle.
func (*Tangle) AttachMessage ¶
AttachMessage attaches a new message to the tangle.
func (*Tangle) DBStats ¶ added in v0.2.2
func (tangle *Tangle) 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 (*Tangle) DeleteMessage ¶
DeleteMessage deletes a message and its association to approvees by un-marking the given message as an approver.
func (*Tangle) DeleteMissingMessage ¶ added in v0.2.2
DeleteMissingMessage deletes a message from the missingMessageStorage.
func (*Tangle) Message ¶
func (tangle *Tangle) Message(messageID message.ID) *message.CachedMessage
Message retrieves a message from the tangle.
func (*Tangle) MessageMetadata ¶
func (tangle *Tangle) MessageMetadata(messageID message.ID) *CachedMessageMetadata
MessageMetadata retrieves the metadata of a message from the tangle.
func (*Tangle) MissingMessages ¶ added in v0.2.2
MissingMessages return the ids of messages in missingMessageStorage
func (*Tangle) Prune ¶
Prune resets the database and deletes all objects (good for testing or "node resets").
func (*Tangle) RetrieveAllTips ¶ added in v0.2.2
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 (*Tangle) Shutdown ¶
Shutdown marks the tangle as stopped, so it will not accept any new messages (waits for all backgroundTasks to finish).
func (*Tangle) SolidifierWorkerPoolStatus ¶ added in v0.2.2
SolidifierWorkerPoolStatus returns the name and the load of the workerpool.
func (*Tangle) StoreMessageWorkerPoolStatus ¶ added in v0.2.2
StoreMessageWorkerPoolStatus returns the name and the load of the workerpool.