message

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const IDLength = 64

IDLength defines the length of an ID.

Variables

View Source
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

type ID [IDLength]byte

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

func IDFromBytes(bytes []byte) (result ID, consumedBytes int, err error)

IDFromBytes unmarshals a message id from a sequence of bytes.

func NewID added in v0.2.3

func NewID(base58EncodedString string) (result ID, err error)

NewID creates a new message id.

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) Bytes added in v0.2.3

func (id ID) Bytes() []byte

Bytes returns the bytes of the ID.

func (*ID) MarshalBinary added in v0.2.3

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

MarshalBinary marshals the ID into bytes.

func (ID) String added in v0.2.3

func (id ID) String() string

String returns the base58 encode of the ID.

func (*ID) UnmarshalBinary added in v0.2.3

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

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) BranchID added in v0.2.3

func (message *Message) BranchID() ID

BranchID returns the id of the branch message.

func (*Message) Bytes

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

Bytes returns the message in serialized byte form.

func (*Message) ContentID added in v0.2.3

func (message *Message) ContentID() (result ContentID)

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

func (message *Message) ID() (result ID)

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

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

IssuerPublicKey returns the public key of the message issuer.

func (*Message) IssuingTime

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

IssuingTime returns the time when this message was created.

func (*Message) Nonce

func (message *Message) Nonce() uint64

Nonce returns the nonce of the message.

func (*Message) ObjectStorageKey

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

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

func (*Message) ObjectStorageValue

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

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

func (*Message) Payload

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

Payload returns the payload of the message.

func (*Message) SequenceNumber

func (message *Message) SequenceNumber() uint64

SequenceNumber returns the sequence number of this message.

func (*Message) Signature

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

Signature returns the signature of the message.

func (*Message) String

func (message *Message) String() string

func (*Message) TrunkID added in v0.2.3

func (message *Message) TrunkID() ID

TrunkID returns the id of the trunk message.

func (*Message) UnmarshalObjectStorageValue

func (message *Message) UnmarshalObjectStorageValue(data []byte) (consumedBytes int, err error)

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

func (message *Message) VerifySignature() bool

VerifySignature verifies the signature of the message.

Jump to

Keyboard shortcuts

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