Documentation ¶
Index ¶
- Constants
- Variables
- type GenericDataPayload
- func GenericDataPayloadFromBytes(bytes []byte) (genericDataPayload *GenericDataPayload, consumedBytes int, err error)
- func GenericDataPayloadFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (genericDataPayload *GenericDataPayload, err error)
- func NewGenericDataPayload(data []byte) *GenericDataPayload
- type Payload
- type Type
- type UnmarshalerFunc
Constants ¶
const MaxSize = 65157
MaxSize defines the maximum allowed size of a marshaled Payload (in bytes). MaxPayloadSize = MaxMessageSize -
(version(1) + parentsCount(1) + parentsType(1) + maxParents(8) * 32 + issuerPK(32) + issuanceTime(8) + seqNum(8) + nonce(8) + signature(64) = MaxMessageSize - 379 bytes = 65157
const TypeLength = marshalutil.Uint32Size
TypeLength contains the amount of bytes of a marshaled Type.
Variables ¶
var GenericDataPayloadType = NewType(0, "GenericDataPayloadType", GenericDataPayloadUnmarshaler)
GenericDataPayloadType is the Type of a generic GenericDataPayload.
Functions ¶
This section is empty.
Types ¶
type GenericDataPayload ¶
type GenericDataPayload struct {
// contains filtered or unexported fields
}
GenericDataPayload represents a payload which just contains a blob of data.
func GenericDataPayloadFromBytes ¶
func GenericDataPayloadFromBytes(bytes []byte) (genericDataPayload *GenericDataPayload, consumedBytes int, err error)
GenericDataPayloadFromBytes unmarshals a GenericDataPayload from a sequence of bytes.
func GenericDataPayloadFromMarshalUtil ¶
func GenericDataPayloadFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (genericDataPayload *GenericDataPayload, err error)
GenericDataPayloadFromMarshalUtil unmarshals a GenericDataPayload using a MarshalUtil (for easier unmarshaling).
func NewGenericDataPayload ¶
func NewGenericDataPayload(data []byte) *GenericDataPayload
NewGenericDataPayload creates new GenericDataPayload.
func (*GenericDataPayload) Blob ¶
func (g *GenericDataPayload) Blob() []byte
Blob returns the contained data of the GenericDataPayload (without its type and size headers).
func (*GenericDataPayload) Bytes ¶
func (g *GenericDataPayload) Bytes() []byte
Bytes returns a marshaled version of the Payload.
func (*GenericDataPayload) String ¶
func (g *GenericDataPayload) String() string
String returns a human readable version of the Payload.
func (*GenericDataPayload) Type ¶
func (g *GenericDataPayload) Type() Type
Type returns the Type of the Payload.
type Payload ¶
type Payload interface { // Type returns the Type of the Payload. Type() Type // Bytes returns a marshaled version of the Payload. Bytes() []byte // String returns a human readable version of the Payload. String() string }
Payload represents the generic interface for an object that can be embedded in Messages of the Tangle.
func FromMarshalUtil ¶
func FromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (payload Payload, err error)
FromMarshalUtil unmarshals a Payload using a MarshalUtil (for easier unmarshaling).
func GenericDataPayloadUnmarshaler ¶
GenericDataPayloadUnmarshaler is the UnmarshalerFunc of the GenericDataPayload which is also used as a unmarshaler for unknown Types.
type Type ¶
type Type uint32
Type represents the Type of a payload.
func NewType ¶
func NewType(typeNumber uint32, typeName string, typeUnmarshaler UnmarshalerFunc) (payloadType Type)
NewType creates and registers a new payload Type.
func TypeFromBytes ¶
TypeFromBytes unmarshals a Type from a sequence of bytes.
func TypeFromMarshalUtil ¶
func TypeFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (typeResult Type, err error)
TypeFromMarshalUtil unmarshals a Type using a MarshalUtil (for easier unmarshaling).
type UnmarshalerFunc ¶
UnmarshalerFunc defines the function signature for functions that can unmarshal Payloads.
func Unmarshaler ¶
func Unmarshaler(payloadType Type) UnmarshalerFunc
Unmarshaler returns the UnmarshalerFunc for the given Type or the GenericDataPayloadUnmarshaler if the Type is unknown.