Documentation
¶
Index ¶
- Constants
- Variables
- func StorableObjectFromKey(key []byte, optionalTargetObject ...*Message) (result objectstorage.StorableObject, consumedBytes int, err error)
- type CachedMessage
- type ContentID
- type ID
- type Message
- func FromBytes(bytes []byte, optionalTargetObject ...*Message) (result *Message, consumedBytes int, err error)
- func New(trunkID ID, branchID ID, issuingTime time.Time, ...) (result *Message)
- func Parse(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Message) (result *Message, err error)
- func (message *Message) BranchID() ID
- func (message *Message) Bytes() []byte
- func (message *Message) ContentID() (result ContentID)
- func (message *Message) ID() (result ID)
- func (message *Message) IssuerPublicKey() ed25519.PublicKey
- func (message *Message) IssuingTime() time.Time
- func (message *Message) Nonce() uint64
- func (message *Message) ObjectStorageKey() []byte
- func (message *Message) ObjectStorageValue() []byte
- func (message *Message) Payload() payload.Payload
- func (message *Message) SequenceNumber() uint64
- func (message *Message) Signature() ed25519.Signature
- func (message *Message) String() string
- func (message *Message) TrunkID() ID
- func (message *Message) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)
- func (message *Message) Update(objectstorage.StorableObject)
- func (message *Message) VerifySignature() bool
Constants ¶
const IDLength = 64
IDLength defines the length of an ID.
Variables ¶
var EmptyID = ID{}
EmptyID is an empty id.
Functions ¶
func StorableObjectFromKey ¶
func StorableObjectFromKey(key []byte, optionalTargetObject ...*Message) (result objectstorage.StorableObject, consumedBytes int, err error)
StorableObjectFromKey gets called when we restore a message from storage. The bytes and the content will be unmarshaled by an external caller (the objectStorage factory).
Types ¶
type CachedMessage ¶
type CachedMessage struct {
objectstorage.CachedObject
}
CachedMessage defines a cached message. A wrapper for a cached object.
func (*CachedMessage) Consume ¶
func (cachedMessage *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 (cachedMessage *CachedMessage) Retain() *CachedMessage
Retain registers a new consumer for the cached message.
func (*CachedMessage) Unwrap ¶
func (cachedMessage *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 ContentID ¶ added in v0.2.3
type ContentID = ID
ContentID identifies the content of a message without its trunk/branch ids.
type ID ¶ added in v0.2.3
ID identifies a message in its entirety. Unlike the sole content id, it also incorporates the trunk and branch ids.
func IDFromBytes ¶ added in v0.2.3
IDFromBytes unmarshals a message id from a sequence of bytes.
func ParseID ¶ added in v0.2.3
func ParseID(marshalUtil *marshalutil.MarshalUtil) (ID, error)
ParseID is a wrapper for simplified unmarshaling in a byte stream using the marshalUtil package.
func (*ID) MarshalBinary ¶ added in v0.2.3
MarshalBinary marshals the ID into bytes.
func (*ID) UnmarshalBinary ¶ added in v0.2.3
UnmarshalBinary unmarshals the bytes into an ID.
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 FromBytes ¶
func FromBytes(bytes []byte, optionalTargetObject ...*Message) (result *Message, consumedBytes int, err error)
FromBytes parses the given bytes into a message.
func New ¶
func New(trunkID ID, branchID ID, issuingTime time.Time, issuerPublicKey ed25519.PublicKey, sequenceNumber uint64, payload payload.Payload, nonce uint64, signature ed25519.Signature) (result *Message)
New creates a new message with the details provided by the issuer.
func Parse ¶
func Parse(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Message) (result *Message, err error)
Parse parses a message from the given marshal util.
func (*Message) ContentID ¶ added in v0.2.3
ContentID returns the content id of the message which is made up of all the parts of the message minus the trunk and branch ids.
func (*Message) ID ¶ added in v0.2.3
ID returns the id of the message which is made up of the content id and trunk/branch 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) SequenceNumber ¶
SequenceNumber returns the sequence number of this message.
func (*Message) UnmarshalObjectStorageValue ¶
UnmarshalObjectStorageValue unmarshals the bytes into a message.
func (*Message) Update ¶
func (message *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.