Documentation ¶
Index ¶
- Constants
- Variables
- func ApproverFromObjectStorage(key []byte, _ []byte) (result 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)
- 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) Update(other objectstorage.StorableObject)
- type BytesFilter
- type BytesRejectedEvent
- type CachedApprover
- type CachedApprovers
- type CachedMessage
- type CachedMessageEvent
- type CachedMessageMetadata
- type Events
- type Message
- func (m *Message) Bytes() []byte
- func (m *Message) ForEachParent(consumer func(parent Parent))
- func (m *Message) ForEachStrongParent(consumer func(parent MessageID))
- func (m *Message) ForEachWeakParent(consumer func(parent 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) 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) Bytes() []byte
- 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) SetSolid(solid bool) (modified bool)
- func (m *MessageMetadata) SolidificationTime() time.Time
- func (m *MessageMetadata) Update(other objectstorage.StorableObject)
- type MessageParsedEvent
- type MessageParser
- type MessageParserEvents
- type MessageRejectedEvent
- type MessageRequester
- type MessageRequesterEvents
- type MessageSignatureFilter
- type MessageTipSelector
- type MessageTipSelectorEvents
- 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 MissingMessageAppearedEvent
- type Option
- type Options
- type Parent
- type PowFilter
- type RecentlySeenBytesFilter
- type SendRequestEvent
- type Tangle
- func (t *Tangle) Approvers(messageID MessageID) CachedApprovers
- func (t *Tangle) AttachMessage(msg *Message)
- func (t *Tangle) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64, ...)
- func (t *Tangle) DeleteMessage(messageID MessageID)
- func (t *Tangle) DeleteMissingMessage(messageID MessageID)
- func (t *Tangle) Message(messageID MessageID) *CachedMessage
- func (t *Tangle) MessageMetadata(messageID MessageID) *CachedMessageMetadata
- func (t *Tangle) MissingMessages() (ids []MessageID)
- func (t *Tangle) Prune() error
- func (t *Tangle) RetrieveAllTips() (tips []MessageID)
- func (t *Tangle) Shutdown() *Tangle
- func (t *Tangle) SolidifierWorkerPoolStatus() (name string, load int)
- func (t *Tangle) StoreMessageWorkerPoolStatus() (name string, load int)
- type TipSelector
- type TipSelectorFunc
- 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 // DBSequenceNumber defines the db sequence number. DBSequenceNumber = "seq" )
const ( // DefaultRetryInterval defines the Default Retry Interval of the message requester. DefaultRetryInterval = 10 * time.Second )
Variables ¶
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") )
var EmptyMessageID = MessageID{}
EmptyMessageID is an empty id.
var ( // ZeroWorker is a PoW worker that always returns 0 as the nonce. ZeroWorker = WorkerFunc(func([]byte) (uint64, error) { return 0, nil }) )
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 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.
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 ¶
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) Update ¶
func (a *Approver) Update(other objectstorage.StorableObject)
Update updates the approver. This should should never happen and will panic if attempted.
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 represents the parameters of bytesRejectedEvent
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)) (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)) (consumed bool)
Consume calls *CachedApprover.Consume on element in the list.
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(msg *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 CachedMessageEvent ¶
type CachedMessageEvent struct { Message *CachedMessage MessageMetadata *CachedMessageMetadata }
CachedMessageEvent represents the parameters of cachedMessageEvent
type CachedMessageMetadata ¶
type CachedMessageMetadata struct {
objectstorage.CachedObject
}
CachedMessageMetadata is a wrapper for stored cached object that represents a message metadata.
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 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 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 ¶
ForEachParent executes a consumer func for each parent.
func (*Message) ForEachStrongParent ¶
ForEachStrongParent executes a consumer func for each strong parent.
func (*Message) ForEachWeakParent ¶
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) ParentsCount ¶
ParentsCount returns the total parents count of this message.
func (*Message) SequenceNumber ¶
SequenceNumber returns the sequence number of this message.
func (*Message) StrongParents ¶
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 ¶
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(store kvstore.KVStore, sequenceKey []byte, localIdentity *identity.LocalIdentity, selector TipSelector) *MessageFactory
NewMessageFactory creates a new message factory.
func (*MessageFactory) IssuePayload ¶
func (f *MessageFactory) IssuePayload(p payload.Payload) (*Message, error)
IssuePayload creates a new message including sequence number and tip selection and returns it. It also triggers the MessageConstructed event once it's done, which is for example used by the plugins to listen for messages that shall be attached to the tangle.
func (*MessageFactory) 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 ¶
type MessageIDs []MessageID
MessageIDs is a slice of MessageID.
func (MessageIDs) ToStrings ¶
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) Bytes ¶
func (m *MessageMetadata) Bytes() []byte
Bytes returns a marshaled version of the whole MessageMetadata object.
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) 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) SolidificationTime ¶
func (m *MessageMetadata) SolidificationTime() time.Time
SolidificationTime returns the time when the message was marked to be solid.
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 ¶
MessageParsedEvent represents the parameters of messageParsedEvent
type MessageParser ¶
type MessageParser struct { Events *MessageParserEvents // contains filtered or unexported fields }
MessageParser parses messages and bytes and emits corresponding events for parsed and rejected messages.
func NewMessageParser ¶
func NewMessageParser() (result *MessageParser)
NewMessageParser creates a new message parser.
func (*MessageParser) AddBytesFilter ¶
func (p *MessageParser) AddBytesFilter(filter BytesFilter)
AddBytesFilter adds the given bytes filter to the parser.
func (*MessageParser) AddMessageFilter ¶
func (p *MessageParser) AddMessageFilter(filter MessageFilter)
AddMessageFilter adds a new message filter to the parser.
type MessageParserEvents ¶
type MessageParserEvents 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 }
MessageParserEvents represents events happening on a message parser.
type MessageRejectedEvent ¶
MessageRejectedEvent represents the parameters of messageRejectedEvent
type MessageRequester ¶
type MessageRequester struct { Events *MessageRequesterEvents // contains filtered or unexported fields }
MessageRequester takes care of requesting messages.
func NewMessageRequester ¶
func NewMessageRequester(missingMessages []MessageID, optionalOptions ...Option) *MessageRequester
NewMessageRequester creates a new message requester.
func (*MessageRequester) RequestQueueSize ¶
func (r *MessageRequester) RequestQueueSize() int
RequestQueueSize returns the number of scheduled message requests.
func (*MessageRequester) StartRequest ¶
func (r *MessageRequester) StartRequest(id MessageID)
StartRequest initiates a regular triggering of the StartRequest event until it has been stopped using StopRequest.
func (*MessageRequester) StopRequest ¶
func (r *MessageRequester) StopRequest(id MessageID)
StopRequest stops requests for the given message to further happen.
type MessageRequesterEvents ¶
type MessageRequesterEvents struct { // Fired when a request for a given message should be sent. SendRequest *events.Event // MissingMessageAppeared is triggered when a message is actually present in the node's db although it was still being requested. MissingMessageAppeared *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 MessageTipSelector ¶
type MessageTipSelector struct { Events *MessageTipSelectorEvents // contains filtered or unexported fields }
MessageTipSelector manages a map of tips and emits events for their removal and addition.
func NewMessageTipSelector ¶
func NewMessageTipSelector(tips ...MessageID) *MessageTipSelector
NewMessageTipSelector creates a new tip-selector.
func (*MessageTipSelector) AddTip ¶
func (t *MessageTipSelector) AddTip(msg *Message)
AddTip adds the given message as a tip.
func (*MessageTipSelector) Set ¶
func (t *MessageTipSelector) Set(tips ...MessageID)
Set adds the given messageIDs as tips.
func (*MessageTipSelector) TipCount ¶
func (t *MessageTipSelector) TipCount() int
TipCount the amount of current tips.
func (*MessageTipSelector) Tips ¶
func (t *MessageTipSelector) Tips(count int) (parents []MessageID)
Tips returns count number of tips, maximum MaxParentsCount.
type MessageTipSelectorEvents ¶
type MessageTipSelectorEvents struct { // Fired when a tip is added. TipAdded *events.Event // Fired when a tip is removed. TipRemoved *events.Event }
MessageTipSelectorEvents represents event happening on the tip-selector.
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 MissingMessageAppearedEvent ¶
type MissingMessageAppearedEvent struct {
ID MessageID
}
MissingMessageAppearedEvent represents the parameters of missingMessageAppearedEvent
type Option ¶
type Option func(*Options)
Option is a function which inits an option.
func RetryInterval ¶
RetryInterval creates an option which sets the retry interval to the given value.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds options for a message requester.
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 (f *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 SendRequestEvent ¶
type SendRequestEvent struct {
ID MessageID
}
SendRequestEvent represents the parameters of sendRequestEvent
type Tangle ¶
type Tangle struct { Events *Events // contains filtered or unexported fields }
Tangle represents the base layer of messages.
func (*Tangle) Approvers ¶
func (t *Tangle) Approvers(messageID MessageID) 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 ¶
func (t *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 ¶
DeleteMissingMessage deletes a message from the missingMessageStorage.
func (*Tangle) Message ¶
func (t *Tangle) Message(messageID MessageID) *CachedMessage
Message retrieves a message from the tangle.
func (*Tangle) MessageMetadata ¶
func (t *Tangle) MessageMetadata(messageID MessageID) *CachedMessageMetadata
MessageMetadata retrieves the metadata of a message from the tangle.
func (*Tangle) MissingMessages ¶
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 ¶
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 ¶
SolidifierWorkerPoolStatus returns the name and the load of the workerpool.
func (*Tangle) StoreMessageWorkerPoolStatus ¶
StoreMessageWorkerPoolStatus returns the name and the load of the workerpool.
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().