fftypes

package
v0.0.0-...-93e01a0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTopic will be set as the topic of any messages set without a topic
	DefaultTopic = "default"
)
View Source
const (
	// ShortIDlphabet is designed for easy double-click select
	ShortIDlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
)
View Source
const (

	// SystemNamespace is the system reserved namespace name
	SystemNamespace = "ff_system"
)

Variables

This section is empty.

Functions

func FFEnumValues

func FFEnumValues(t string) []interface{}

func ParseToByteSize

func ParseToByteSize(byteString string) int64

ParseToByteSize is a standard handling of a number of bytes, in config or API options

func ParseToDuration

func ParseToDuration(durationString string) time.Duration

ParseToDuration is a standard handling of any duration string, in config or API options

func SafeHashCompare

func SafeHashCompare(h1 *Bytes32, h2 *Bytes32) bool

func ShortID

func ShortID() string

func ToStringArray

func ToStringArray(unknown interface{}) ([]string, bool)

func TokenAccountIdentifier

func TokenAccountIdentifier(protocolID, tokenIndex, identity string) string

func ValidateFFNameField

func ValidateFFNameField(ctx context.Context, str string, fieldName string) error

func ValidateLength

func ValidateLength(ctx context.Context, str string, fieldName string, max int) error

Types

type Batch

type Batch struct {
	ID         *UUID        `json:"id"`
	Namespace  string       `json:"namespace"`
	Type       MessageType  `json:"type"`
	Author     string       `json:"author"`
	Group      *Bytes32     `jdon:"group,omitempty"`
	Hash       *Bytes32     `json:"hash"`
	Created    *FFTime      `json:"created"`
	Confirmed  *FFTime      `json:"confirmed"`
	Payload    BatchPayload `json:"payload"`
	PayloadRef string       `json:"payloadRef,omitempty"`
	Blobs      []*Bytes32   `json:"blobs,omitempty"` // only used in-flight
}

type BatchPayload

type BatchPayload struct {
	TX       TransactionRef `json:"tx"`
	Messages []*Message     `json:"messages"`
	Data     []*Data        `json:"data"`
}

func (*BatchPayload) Hash

func (ma *BatchPayload) Hash() *Bytes32

func (*BatchPayload) Scan

func (ma *BatchPayload) Scan(src interface{}) error

Scan implements sql.Scanner

func (BatchPayload) Value

func (ma BatchPayload) Value() (driver.Value, error)

Value implements sql.Valuer

type Blob

type Blob struct {
	Hash       *Bytes32 `json:"hash"`
	PayloadRef string   `json:"payloadRef,omitempty"`
	Peer       string   `json:"peer,omitempty"`
	Created    *FFTime  `json:"created,omitempty"`
	Sequence   int64    `json:"-"`
}

type BlobRef

type BlobRef struct {
	Hash   *Bytes32 `json:"hash"`
	Public string   `json:"public,omitempty"`
}

type Byteable

type Byteable []byte

Byteable uses raw encode/decode to preserve field order, and can handle any types of field. It validates the JSON can be unmarshalled, but does not change the order. It does however trim out whitespace

func (Byteable) Hash

func (h Byteable) Hash() *Bytes32

func (Byteable) JSONObject

func (h Byteable) JSONObject() JSONObject

JSONObject attempts to de-serailize the contained structure as a JSON Object (map) Will fail if the type is array, string, bool, number etc.

func (Byteable) JSONObjectOk

func (h Byteable) JSONObjectOk() (JSONObject, bool)

func (Byteable) MarshalJSON

func (h Byteable) MarshalJSON() ([]byte, error)

func (Byteable) String

func (h Byteable) String() string

func (*Byteable) UnmarshalJSON

func (h *Byteable) UnmarshalJSON(b []byte) error

type Bytes32

type Bytes32 [32]byte

Bytes32 is a holder of a hash, that can be used to correlate onchain data with off-chain data.

func HashResult

func HashResult(hash hash.Hash) *Bytes32

func NewRandB32

func NewRandB32() *Bytes32

func ParseBytes32

func ParseBytes32(ctx context.Context, hexStr string) (*Bytes32, error)

func UUIDBytes

func UUIDBytes(u *UUID) *Bytes32

UUIDBytes returns the bytes of a UUID as a compressed hex string

func (*Bytes32) Equals

func (b32 *Bytes32) Equals(b2 *Bytes32) bool

func (Bytes32) MarshalText

func (b32 Bytes32) MarshalText() ([]byte, error)

func (*Bytes32) Scan

func (b32 *Bytes32) Scan(src interface{}) error

Scan implements sql.Scanner

func (*Bytes32) String

func (b32 *Bytes32) String() string

func (*Bytes32) UnmarshalText

func (b32 *Bytes32) UnmarshalText(b []byte) error

func (*Bytes32) Value

func (b32 *Bytes32) Value() (driver.Value, error)

Value implements sql.Valuer

type ChangeEvent

type ChangeEvent struct {
	// The resource collection where the changed resource exists
	Collection string `json:"collection"`
	// The type of event
	Type ChangeEventType `json:"type"`
	// Namespace is set if there is a namespace associated with the changed resource
	Namespace string `json:"namespace,omitempty"`
	// UUID is set if the resource is identified by ID
	ID *UUID `json:"id,omitempty"`
	// Hash is set if the resource is identified primarily by hash (groups is currently the only example)
	Hash *Bytes32 `json:"hash,omitempty"`
	// Sequence is set if there is a local ordered sequence associated with the changed resource
	Sequence *int64 `json:"sequence,omitempty"`
}

ChangeEvent is a change to the local FireFly core node.

type ChangeEventType

type ChangeEventType string

ChangeEventType

const (
	ChangeEventTypeCreated ChangeEventType = "created"
	ChangeEventTypeUpdated ChangeEventType = "updated" // note bulk updates might not results in change events.
	ChangeEventTypeDeleted ChangeEventType = "deleted"
)

type ConfigRecord

type ConfigRecord struct {
	Key   string   `json:"key,omitempty"`
	Value Byteable `json:"value,omitempty"`
}

type DXInfo

type DXInfo struct {
	Peer     string     `json:"peer,omitempty"`
	Endpoint JSONObject `json:"endpoint,omitempty"`
}

DXInfo is the data exchange information

type Data

type Data struct {
	ID        *UUID         `json:"id,omitempty"`
	Validator ValidatorType `json:"validator"`
	Namespace string        `json:"namespace,omitempty"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	Created   *FFTime       `json:"created,omitempty"`
	Datatype  *DatatypeRef  `json:"datatype,omitempty"`
	Value     Byteable      `json:"value"`
	Blob      *BlobRef      `json:"blob,omitempty"`
}

func (*Data) CalcHash

func (d *Data) CalcHash(ctx context.Context) (*Bytes32, error)

func (*Data) Seal

func (d *Data) Seal(ctx context.Context) (err error)

type DataAndBlob

type DataAndBlob struct {
	Data *Data
	Blob *Blob
}

type DataRef

type DataRef struct {
	ID   *UUID    `json:"id,omitempty"`
	Hash *Bytes32 `json:"hash,omitempty"`
}

type DataRefOrValue

type DataRefOrValue struct {
	DataRef

	Validator ValidatorType `json:"validator,omitempty"`
	Datatype  *DatatypeRef  `json:"datatype,omitempty"`
	Value     Byteable      `json:"value,omitempty"`
	Blob      *BlobRef      `json:"blob,omitempty"`
}

DataRefOrValue allows a value to be specified in-line in the data array of an input message, avoiding the need for a multiple API calls.

type DataRefs

type DataRefs []*DataRef

func (DataRefs) Hash

func (d DataRefs) Hash() *Bytes32

type Datatype

type Datatype struct {
	ID        *UUID         `json:"id,omitempty"`
	Message   *UUID         `json:"message,omitempty"`
	Validator ValidatorType `json:"validator" ffenum:"validatortype"`
	Namespace string        `json:"namespace,omitempty"`
	Name      string        `json:"name,omitempty"`
	Version   string        `json:"version,omitempty"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	Created   *FFTime       `json:"created,omitempty"`
	Value     Byteable      `json:"value,omitempty"`
}

Datatype is the structure defining a data definition, such as a JSON schema

func (*Datatype) SetBroadcastMessage

func (dt *Datatype) SetBroadcastMessage(msgID *UUID)

func (*Datatype) Topic

func (dt *Datatype) Topic() string

func (*Datatype) Validate

func (dt *Datatype) Validate(ctx context.Context, existing bool) (err error)

type DatatypeRef

type DatatypeRef struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

func (*DatatypeRef) String

func (dr *DatatypeRef) String() string

type Definition

type Definition interface {
	// Topic returns the topic on which the object should be broadcast
	Topic() string
	// SetBroadcastMessage sets the message that broadcast the definition
	SetBroadcastMessage(msgID *UUID)
}

Definition is implemented by all objects that can be broadcast as system definitions to the network

type EmptyInput

type EmptyInput struct{}

EmptyInput represents an API with no input fields, but requiring a JSON content type on the request

type Event

type Event struct {
	ID        *UUID     `json:"id"`
	Sequence  int64     `json:"sequence"`
	Type      EventType `json:"type" ffenum:"eventtype"`
	Namespace string    `json:"namespace"`
	Reference *UUID     `json:"reference"`
	Created   *FFTime   `json:"created"`
}

Event is an activity in the system, delivered reliably to applications, that indicates something has happened in the network

func NewEvent

func NewEvent(t EventType, ns string, ref *UUID) *Event

func (*Event) LocalSequence

func (e *Event) LocalSequence() int64

type EventDelivery

type EventDelivery struct {
	Event
	Subscription SubscriptionRef `json:"subscription"`
	Message      *Message        `json:"message,omitempty"`
}

EventDelivery adds the referred object to an event, as well as details of the subscription that caused the event to be dispatched to an applciation.

type EventDeliveryResponse

type EventDeliveryResponse struct {
	ID           *UUID           `json:"id"`
	Rejected     bool            `json:"rejected,omitempty"`
	Info         string          `json:"info,omitempty"`
	Subscription SubscriptionRef `json:"subscription"`
	Reply        *MessageInOut   `json:"reply,omitempty"`
}

EventDeliveryResponse is the payload an application sends back, to confirm it has accepted (or rejected) the event and as such does not need to receive it again.

type EventType

type EventType = FFEnum

EventType indicates what the event means, as well as what the Reference in the event refers to

var (
	// EventTypeMessageConfirmed is the most important event type in the system. This means a message and all of its data
	// is available for processing by an application. Most applications only need to listen to this event type
	EventTypeMessageConfirmed EventType = ffEnum("eventtype", "message_confirmed")
	// EventTypeMessageRejected occurs if a message is received and confirmed from a sequencing perspective, but is rejected as invalid (mismatch to schema, or duplicate system broadcast)
	EventTypeMessageRejected EventType = ffEnum("eventtype", "message_rejected")
	// EventTypeNamespaceConfirmed occurs when a new namespace is ready for use (on the namespace itself)
	EventTypeNamespaceConfirmed EventType = ffEnum("eventtype", "namespace_confirmed")
	// EventTypeDatatypeConfirmed occurs when a new datatype is ready for use (on the namespace of the datatype)
	EventTypeDatatypeConfirmed EventType = ffEnum("eventtype", "datatype_confirmed")
	// EventTypeGroupConfirmed occurs when a new group is ready to use (on the namespace of the group, on all group participants)
	EventTypeGroupConfirmed EventType = ffEnum("eventtype", "group_confirmed")
	// EventTypePoolConfirmed occurs when a new token pool is ready for use
	EventTypePoolConfirmed EventType = ffEnum("eventtype", "token_pool_confirmed")
	// EventTypePoolRejected occurs when a new token pool is rejected (due to validation errors, duplicates, etc)
	EventTypePoolRejected EventType = ffEnum("eventtype", "token_pool_rejected")
)

type FFDuration

type FFDuration time.Duration

FFDuration is serialized to JSON in the string format of time.Duration It can be unmarshalled from a number, or a string. - If it is a string in time.Duration format, that will be used - If it is a string that can be parsed as an int64, that will be used in Milliseconds - If it is a number, that will be used in Milliseconds

func ParseDurationString

func ParseDurationString(durationString string, def time.Duration) (FFDuration, error)

ParseDurationString is a standard handling of any duration string, in config or API options

func (*FFDuration) MarshalJSON

func (fd *FFDuration) MarshalJSON() ([]byte, error)

func (*FFDuration) Scan

func (fd *FFDuration) Scan(src interface{}) error

Scan implements sql.Scanner

func (*FFDuration) String

func (fd *FFDuration) String() string

func (*FFDuration) UnmarshalJSON

func (fd *FFDuration) UnmarshalJSON(b []byte) error

func (*FFDuration) Value

func (fd *FFDuration) Value() (driver.Value, error)

Value implements sql.Valuer

type FFEnum

type FFEnum string

func (FFEnum) Equals

func (ts FFEnum) Equals(ts2 FFEnum) bool

func (FFEnum) Lower

func (ts FFEnum) Lower() FFEnum

func (FFEnum) String

func (ts FFEnum) String() string

func (*FFEnum) UnmarshalText

func (ts *FFEnum) UnmarshalText(b []byte) error

func (FFEnum) Value

func (ts FFEnum) Value() (driver.Value, error)

type FFNameArray

type FFNameArray []string

FFNameArray is an array of strings, each conforming to the requirements of a FireFly name, with a combined length (when joined with commas) of 1024

func (*FFNameArray) Scan

func (na *FFNameArray) Scan(src interface{}) error

func (FFNameArray) String

func (na FFNameArray) String() string

func (FFNameArray) Validate

func (na FFNameArray) Validate(ctx context.Context, fieldName string) error

func (FFNameArray) Value

func (na FFNameArray) Value() (driver.Value, error)

type FFTime

type FFTime time.Time

FFTime is serialized to JSON on the API in RFC3339 nanosecond UTC time (noting that JavaScript can parse this format happily into millisecond time with Date.pase()). It is persisted as a nanosecond resolution timestamp in the database. It can be parsed from RFC3339, or unix timestamps (second, millisecond or nanosecond resolution)

func Now

func Now() *FFTime

func ParseString

func ParseString(str string) (*FFTime, error)

func UnixTime

func UnixTime(unixTime int64) *FFTime

func ZeroTime

func ZeroTime() FFTime

func (*FFTime) Equal

func (ft *FFTime) Equal(ft2 *FFTime) bool

func (*FFTime) MarshalJSON

func (ft *FFTime) MarshalJSON() ([]byte, error)

func (*FFTime) Scan

func (ft *FFTime) Scan(src interface{}) error

Scan implements sql.Scanner

func (FFTime) String

func (ft FFTime) String() string

func (*FFTime) UnixNano

func (ft *FFTime) UnixNano() int64

func (*FFTime) UnmarshalText

func (ft *FFTime) UnmarshalText(b []byte) error

func (FFTime) Value

func (ft FFTime) Value() (driver.Value, error)

Value implements sql.Valuer

type Group

type Group struct {
	GroupIdentity
	Message *UUID    `json:"message,omitempty"`
	Hash    *Bytes32 `json:"hash,omitempty"`
	Created *FFTime  `json:"created,omitempty"`
}

func (*Group) Seal

func (group *Group) Seal()

func (*Group) SetBroadcastMessage

func (group *Group) SetBroadcastMessage(msgID *UUID)

func (*Group) Topic

func (group *Group) Topic() string

func (*Group) Validate

func (group *Group) Validate(ctx context.Context, existing bool) (err error)

type GroupIdentity

type GroupIdentity struct {
	Ledger    *UUID   `json:"ledger,omitempty"`
	Namespace string  `json:"namespace,omitempty"`
	Name      string  `json:"name"`
	Members   Members `json:"members"`
}

func (*GroupIdentity) Hash

func (man *GroupIdentity) Hash() *Bytes32

type HexUUID

type HexUUID = Bytes32

HexUUID is 32 character ASCII string containing the hex representation of UUID, with the dashes of the canonical representation removed

type Identity

type Identity struct {
	Identifier string `json:"identifier,omitempty"`
	OnChain    string `json:"onchain,omitempty"`
}

Identity is a structure used to keep track of and map identity in the system.

TODO: Mapping of more sophisticate identities (DIDs etc.) via plugins, and richer interface

type InlineData

type InlineData []*DataRefOrValue

InlineData is an array of data references or values

type InputGroup

type InputGroup struct {
	Name    string        `json:"name,omitempty"`
	Ledger  *UUID         `json:"ledger,omitempty"`
	Members []MemberInput `json:"members"`
}

InputGroup declares a group in-line for auotmatic resolution, without having to define a group up-front

type JSONObject

type JSONObject map[string]interface{}

JSONObject is a holder of a hash, that can be used to correlate onchain data with off-chain data.

func (JSONObject) GetBool

func (jd JSONObject) GetBool(key string) bool

func (JSONObject) GetObject

func (jd JSONObject) GetObject(key string) JSONObject

func (JSONObject) GetObjectArray

func (jd JSONObject) GetObjectArray(key string) JSONObjectArray

func (JSONObject) GetObjectArrayOk

func (jd JSONObject) GetObjectArrayOk(key string) (JSONObjectArray, bool)

func (JSONObject) GetObjectOk

func (jd JSONObject) GetObjectOk(key string) (JSONObject, bool)

func (JSONObject) GetString

func (jd JSONObject) GetString(key string) string

func (JSONObject) GetStringArray

func (jd JSONObject) GetStringArray(key string) []string

func (JSONObject) GetStringArrayOk

func (jd JSONObject) GetStringArrayOk(key string) ([]string, bool)

func (JSONObject) GetStringOk

func (jd JSONObject) GetStringOk(key string) (string, bool)

func (JSONObject) Hash

func (jd JSONObject) Hash(jsonDesc string) (*Bytes32, error)

func (*JSONObject) Scan

func (jd *JSONObject) Scan(src interface{}) error

Scan implements sql.Scanner

func (JSONObject) String

func (jd JSONObject) String() string

func (JSONObject) Value

func (jd JSONObject) Value() (driver.Value, error)

Value implements sql.Valuer

type JSONObjectArray

type JSONObjectArray []JSONObject

JSONObjectArray is an array of JSONObject

func ToJSONObjectArray

func ToJSONObjectArray(unknown interface{}) (JSONObjectArray, bool)

func (JSONObjectArray) Hash

func (jd JSONObjectArray) Hash(jsonDesc string) (*Bytes32, error)

func (*JSONObjectArray) Scan

func (jd *JSONObjectArray) Scan(src interface{}) error

Scan implements sql.Scanner

func (JSONObjectArray) String

func (jd JSONObjectArray) String() string

func (JSONObjectArray) Value

func (jd JSONObjectArray) Value() (driver.Value, error)

type LocallySequenced

type LocallySequenced interface {
	LocalSequence() int64
}

type Member

type Member struct {
	Identity string `json:"identity,omitempty"`
	Node     *UUID  `json:"node,omitempty"`
}

type MemberInput

type MemberInput struct {
	Identity string `json:"identity,omitempty"`
	Node     string `json:"node,omitempty"`
}

type Members

type Members []*Member

func (Members) Len

func (m Members) Len() int

func (Members) Less

func (m Members) Less(i, j int) bool

func (Members) Swap

func (m Members) Swap(i, j int)

type Message

type Message struct {
	Header    MessageHeader `json:"header"`
	Hash      *Bytes32      `json:"hash,omitempty"`
	BatchID   *UUID         `json:"batch,omitempty"`
	Local     bool          `json:"local,omitempty"`
	Rejected  bool          `json:"rejected,omitempty"`
	Pending   SortableBool  `json:"pending"`
	Confirmed *FFTime       `json:"confirmed,omitempty"`
	Data      DataRefs      `json:"data"`
	Pins      FFNameArray   `json:"pins,omitempty"`
	Sequence  int64         `json:"-"` // Local database sequence used internally for batch assembly
}

Message is the envelope by which coordinated data exchange can happen between parties in the network Data is passed by reference in these messages, and a chain of hashes covering the data and the details of the message, provides a verification against tampering.

func (*Message) DupDataCheck

func (m *Message) DupDataCheck(ctx context.Context) (err error)

func (*Message) LocalSequence

func (m *Message) LocalSequence() int64

func (*Message) Seal

func (m *Message) Seal(ctx context.Context) (err error)

func (*Message) Verify

func (m *Message) Verify(ctx context.Context) error

type MessageHeader

type MessageHeader struct {
	ID        *UUID           `json:"id,omitempty"`
	CID       *UUID           `json:"cid,omitempty"`
	Type      MessageType     `json:"type" ffenum:"messagetype"`
	TxType    TransactionType `json:"txtype,omitempty"`
	Author    string          `json:"author,omitempty"`
	Created   *FFTime         `json:"created,omitempty"`
	Namespace string          `json:"namespace,omitempty"`
	Group     *Bytes32        `json:"group,omitempty"`
	Topics    FFNameArray     `json:"topics,omitempty"`
	Tag       string          `json:"tag,omitempty"`
	DataHash  *Bytes32        `json:"datahash,omitempty"`
}

MessageHeader contains all fields that contribute to the hash The order of the serialization mut not change, once released

func (*MessageHeader) Hash

func (h *MessageHeader) Hash() *Bytes32

type MessageInOut

type MessageInOut struct {
	Message
	InlineData InlineData  `json:"data"`
	Group      *InputGroup `json:"group,omitempty"`
}

MessageInOut allows API users to submit values in-line in the payload submitted, which will be broken out and stored separately during the call.

func (*MessageInOut) SetInlineData

func (m *MessageInOut) SetInlineData(data []*Data)

type MessageRef

type MessageRef struct {
	ID       *UUID    `json:"id,omitempty"`
	Sequence int64    `json:"sequence,omitempty"`
	Hash     *Bytes32 `json:"hash,omitempty"`
}

MessageRef is a lightweight data structure that can be used to refer to a message

type MessageType

type MessageType = FFEnum

MessageType is the fundamental type of a message

var (
	// MessageTypeDefinition is a message broadcasting a definition of a system type, pre-defined by firefly (namespaces, members, data definitions, etc.)
	MessageTypeDefinition MessageType = ffEnum("messagetype", "definition")
	// MessageTypeBroadcast is a broadcast message, meaning it is intended to be visible by all parties in the network
	MessageTypeBroadcast MessageType = ffEnum("messagetype", "broadcast")
	// MessageTypePrivate is a private message, meaning it is only sent explicitly to individual parties in the network
	MessageTypePrivate MessageType = ffEnum("messagetype", "private")
	// MessageTypeGroupInit is a special private message that contains the definition of the group
	MessageTypeGroupInit MessageType = ffEnum("messagetype", "groupinit")
)

type Multipart

type Multipart struct {
	Filename string
	Mimetype string
	Data     io.Reader
}

Multipart represents streaming data in a multi-part upload

type Named

type Named interface {
	Name() string
}

type Namespace

type Namespace struct {
	ID          *UUID         `json:"id"`
	Message     *UUID         `json:"message,omitempty"`
	Name        string        `json:"name"`
	Description string        `json:"description"`
	Type        NamespaceType `json:"type" ffenum:"namespacetype"`
	Created     *FFTime       `json:"created"`
}

Namespace is a isolate set of named resources, to allow multiple applications to co-exist in the same network, with the same named objects. Can be used for use case segregation, or multi-tenancy.

func (*Namespace) SetBroadcastMessage

func (ns *Namespace) SetBroadcastMessage(msgID *UUID)

func (*Namespace) Topic

func (ns *Namespace) Topic() string

func (*Namespace) Validate

func (ns *Namespace) Validate(ctx context.Context, existing bool) (err error)

type NamespaceType

type NamespaceType = FFEnum

NamespaceType describes when the namespace was created from local configuration, or broadcast through the network

var (
	// NamespaceTypeLocal is a namespace that only exists because it was defined in the local configuration of the node
	NamespaceTypeLocal NamespaceType = ffEnum("namespacetype", "local")
	// NamespaceTypeBroadcast is a namespace that was broadcast through the network. Broadcast namespaces can overwrite a local namespace
	NamespaceTypeBroadcast NamespaceType = ffEnum("namespacetype", "broadcast")
	// NamespaceTypeSystem is a reserved namespace used by FireFly itself
	NamespaceTypeSystem NamespaceType = ffEnum("namespacetype", "system")
)

type NextPin

type NextPin struct {
	Context  *Bytes32 `json:"context"`
	Identity string   `json:"identity"`
	Hash     *Bytes32 `json:"hash"`
	Nonce    int64    `json:"nonce"`
	Sequence int64    `json:"_"` // Local database sequence used internally for update efficiency
}

type Node

type Node struct {
	ID          *UUID   `json:"id"`
	Message     *UUID   `json:"message,omitempty"`
	Owner       string  `json:"owner,omitempty"`
	Name        string  `json:"name,omitempty"`
	Description string  `json:"description,omitempty"`
	DX          DXInfo  `json:"dx"`
	Created     *FFTime `json:"created,omitempty"`
}

Node is a FireFly node within the network

func (*Node) SetBroadcastMessage

func (n *Node) SetBroadcastMessage(msgID *UUID)

func (*Node) Topic

func (n *Node) Topic() string

func (*Node) Validate

func (n *Node) Validate(ctx context.Context, existing bool) (err error)

type NodeStatus

type NodeStatus struct {
	Node     NodeStatusNode     `json:"node"`
	Org      NodeStatusOrg      `json:"org"`
	Defaults NodeStatusDefaults `json:"defaults"`
}

NodeStatus is a set of information that represents the health, and identity of a node

type NodeStatusDefaults

type NodeStatusDefaults struct {
	Namespace string `json:"namespace"`
}

NodeStatusDefaults is information about core configuration th

type NodeStatusNode

type NodeStatusNode struct {
	Name       string `json:"name"`
	Registered bool   `json:"registered"`
	ID         *UUID  `json:"id,omitempty"`
}

NodeStatusNode is the information about the local node, returned in the node status

type NodeStatusOrg

type NodeStatusOrg struct {
	Name       string `json:"name"`
	Registered bool   `json:"registered"`
	Identity   string `json:"identity,omitempty"`
	ID         *UUID  `json:"id,omitempty"`
}

NodeStatusOrg is the information about the node owning org, returned in the node status

type Nonce

type Nonce struct {
	Context *Bytes32 `json:"hash"`
	Nonce   int64    `json:"nonce"`
	Group   *Bytes32 `json:"group,omitempty"`
	Topic   string   `json:"topic"`
}

Nonce is this local node's state record for the context of a group+topic combination. It records the node's latest allocated sequence number for the context. A context is a hash of a GroupID and a topic, concattenated together

type Offset

type Offset struct {
	Type    OffsetType `json:"type" ffenum:"offsettype"`
	Name    string     `json:"name"`
	Current int64      `json:"current,omitempty"`

	RowID int64 `json:"-"`
}

Offset is a simple stored data structure that records a sequence position within another collection

type OffsetType

type OffsetType = FFEnum
var (
	// OffsetTypeBatch is an offset stored by the batch manager on the messages table
	OffsetTypeBatch OffsetType = ffEnum("offsettype", "batch")
	// OffsetTypeAggregator is an offset stored by the aggregator on the events table
	OffsetTypeAggregator OffsetType = ffEnum("offsettype", "aggregator")
	// OffsetTypeSubscription is an offeset stored by a dispatcher on the events table
	OffsetTypeSubscription OffsetType = ffEnum("offsettype", "subscription")
)

type OpStatus

type OpStatus string

OpStatus is the current status of an operation

const (
	// OpStatusPending indicates the operation has been submitted, but is not yet confirmed as successful or failed
	OpStatusPending OpStatus = "Pending"
	// OpStatusSucceeded the infrastructure runtime has returned success for the operation.
	OpStatusSucceeded OpStatus = "Succeeded"
	// OpStatusFailed happens when an error is reported by the infrastructure runtime
	OpStatusFailed OpStatus = "Failed"
)

type OpType

type OpType = FFEnum

OpType describes mechanical steps in the process that have to be performed, might be asynchronous, and have results in the back-end systems that might need to be correlated with messages by operators.

var (
	// OpTypeBlockchainBatchPin is a blockchain transaction to pin a batch
	OpTypeBlockchainBatchPin OpType = ffEnum("optype", "blockchain_batch_pin")
	// OpTypePublicStorageBatchBroadcast is a public storage operation to store broadcast data
	OpTypePublicStorageBatchBroadcast OpType = ffEnum("optype", "publicstorage_batch_broadcast")
	// OpTypeDataExchangeBatchSend is a private send
	OpTypeDataExchangeBatchSend OpType = ffEnum("optype", "dataexchange_batch_send")
	// OpTypeDataExchangeBlobSend is a private send
	OpTypeDataExchangeBlobSend OpType = ffEnum("optype", "dataexchange_blob_send")
	// OpTypeTokensCreatePool is a token pool creation
	OpTypeTokensCreatePool OpType = ffEnum("optype", "tokens_create_pool")
)

type Operation

type Operation struct {
	ID          *UUID      `json:"id"`
	Namespace   string     `json:"namespace"`
	Transaction *UUID      `json:"tx"`
	Type        OpType     `json:"type" ffenum:"optype"`
	Member      string     `json:"member,omitempty"`
	Status      OpStatus   `json:"status"`
	Error       string     `json:"error,omitempty"`
	Plugin      string     `json:"plugin"`
	BackendID   string     `json:"backendId"`
	Input       JSONObject `json:"input,omitempty"`
	Output      JSONObject `json:"output,omitempty"`
	Created     *FFTime    `json:"created,omitempty"`
	Updated     *FFTime    `json:"updated,omitempty"`
}

Operation is a description of an action performed as part of a transaction submitted by this node

func NewTXOperation

func NewTXOperation(plugin Named, namespace string, tx *UUID, backendID string, opType OpType, opStatus OpStatus, member string) *Operation

NewTXOperation creates a new operation for a transaction

type Organization

type Organization struct {
	ID          *UUID      `json:"id"`
	Message     *UUID      `json:"message,omitempty"`
	Parent      string     `json:"parent,omitempty"`
	Identity    string     `json:"identity,omitempty"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	Profile     JSONObject `json:"profile,omitempty"`
	Created     *FFTime    `json:"created,omitempty"`
}

Organization is a top-level identity in the network

func (*Organization) SetBroadcastMessage

func (org *Organization) SetBroadcastMessage(msgID *UUID)

func (*Organization) Topic

func (org *Organization) Topic() string

func (*Organization) Validate

func (org *Organization) Validate(ctx context.Context, existing bool) (err error)

type Pin

type Pin struct {
	Sequence   int64    `json:"sequence,omitempty"`
	Masked     bool     `json:"masked,omitempty"`
	Hash       *Bytes32 `json:"hash,omitempty"`
	Batch      *UUID    `json:"batch,omitempty"`
	Index      int64    `json:"index,omitempty"`
	Dispatched bool     `json:"dispatched,omitempty"`
	Created    *FFTime  `json:"created,omitempty"`
}

Pin represents a ledger-pinning event that has been detected from the blockchain, in the sequence that it was detected.

A batch contains many messages, and each of those messages can be on a different topic (or topics) All messages on the same topic must be processed in the order that the batch pinning events arrive from the blockchain.

As we need to correlate the on-chain events, with off-chain data that might arrive at a different time (or never), we "park" all pinned sequences first, then only complete them (and generate the associated events) once all the data has been assembled for all messages on that sequence, within that batch.

We might park the pin first (from the blockchain), or park the batch first (if it arrived first off-chain). There's a third part as well that can block a message, which is large blob data moving separately to the batch. If we get the private message, then the batch, before receiving the blob data - we have to upgrade a batch-park, to a pin-park. This is because the sequence must be in the order the pins arrive.

func (*Pin) LocalSequence

func (p *Pin) LocalSequence() int64

type RESTError

type RESTError struct {
	Error string `json:"error"`
}

type SortableBool

type SortableBool bool

SortableBool is a boolean, which is stored as a SMALLINT in databases where sorting/indexing by a BOOLEAN type is not consistently supported. TRUE>FALSE

func (*SortableBool) Scan

func (sb *SortableBool) Scan(src interface{}) error

func (SortableBool) Value

func (sb SortableBool) Value() (driver.Value, error)

type SubOptsFirstEvent

type SubOptsFirstEvent string

SubOptsFirstEvent picks the first event that should be dispatched on the subscription, and can be a string containing an exact sequence as well as one of the enum values

const (
	// SubOptsFirstEventOldest indicates all events should be dispatched to the subscription
	SubOptsFirstEventOldest SubOptsFirstEvent = "oldest"
	// SubOptsFirstEventNewest indicates only newly received events should be dispatched to the subscription
	SubOptsFirstEventNewest SubOptsFirstEvent = "newest"
)

type Subscription

type Subscription struct {
	SubscriptionRef

	Transport string              `json:"transport"`
	Filter    SubscriptionFilter  `json:"filter"`
	Options   SubscriptionOptions `json:"options"`
	Ephemeral bool                `json:"ephemeral,omitempty"`
	Created   *FFTime             `json:"created"`
	Updated   *FFTime             `json:"updated"`
}

Subscription is a binding between the stream of events within a namespace, and an event interface - such as an application listening on websockets

type SubscriptionCoreOptions

type SubscriptionCoreOptions struct {
	FirstEvent *SubOptsFirstEvent `json:"firstEvent,omitempty"`
	ReadAhead  *uint16            `json:"readAhead,omitempty"`
	WithData   *bool              `json:"withData,omitempty"`
}

SubscriptionCoreOptions are the core options that apply across all transports

type SubscriptionFilter

type SubscriptionFilter struct {
	Events string `json:"events,omitempty"`
	Topics string `json:"topics,omitempty"`
	Tag    string `json:"tag,omitempty"`
	Group  string `json:"group,omitempty"`
	Author string `json:"author,omitempty"`
}

SubscriptionFilter contains regular expressions to match against events. All must match for an event to be dispatched to a subscription

type SubscriptionOptions

type SubscriptionOptions struct {
	SubscriptionCoreOptions

	// Ephemeral subscriptions only can add this option to enable change events
	ChangeEvents bool `json:"-"`
	// contains filtered or unexported fields
}

SubscriptionOptions cutomize the behavior of subscriptions

func (SubscriptionOptions) MarshalJSON

func (so SubscriptionOptions) MarshalJSON() ([]byte, error)

func (*SubscriptionOptions) Scan

func (so *SubscriptionOptions) Scan(src interface{}) error

Scan implements sql.Scanner

func (*SubscriptionOptions) TransportOptions

func (so *SubscriptionOptions) TransportOptions() JSONObject

func (*SubscriptionOptions) UnmarshalJSON

func (so *SubscriptionOptions) UnmarshalJSON(b []byte) error

func (SubscriptionOptions) Value

func (so SubscriptionOptions) Value() (driver.Value, error)

Value implements sql.Valuer

type SubscriptionRef

type SubscriptionRef struct {
	ID        *UUID  `json:"id"`
	Namespace string `json:"namespace"`
	Name      string `json:"name"`
}

SubscriptionRef are the fields that can be used to refer to a subscription

type SystemTag

type SystemTag string
const (

	// SystemTagDefineDatatype is the topic for messages that broadcast data definitions
	SystemTagDefineDatatype SystemTag = "ff_define_datatype"

	// SystemTagDefineNamespace is the topic for messages that broadcast namespace definitions
	SystemTagDefineNamespace SystemTag = "ff_define_namespace"

	// SystemTagDefineOrganization is the topic for messages that broadcast organization definitions
	SystemTagDefineOrganization SystemTag = "ff_define_organization"

	// SystemTagDefineNode is the topic for messages that broadcast node definitions
	SystemTagDefineNode SystemTag = "ff_define_node"

	// SystemTagDefineGroup is the topic for messages that send the definition of a group, to all parties in that group
	SystemTagDefineGroup SystemTag = "ff_define_group"
)

type TokenAccount

type TokenAccount struct {
	ProtocolID string `json:"protocolId,omitempty"`
	TokenIndex string `json:"tokenIndex,omitempty"`
	Identity   string `json:"identity,omitempty"`
	Balance    int64  `json:"balance"`
}

func (*TokenAccount) Identifier

func (a *TokenAccount) Identifier() string

type TokenPool

type TokenPool struct {
	ID         *UUID          `json:"id,omitempty"`
	Type       TokenType      `json:"type" ffenum:"tokentype"`
	Namespace  string         `json:"namespace,omitempty"`
	Name       string         `json:"name,omitempty"`
	ProtocolID string         `json:"protocolId,omitempty"`
	Author     string         `json:"author,omitempty"`
	Symbol     string         `json:"symbol,omitempty"`
	Connector  string         `json:"connector,omitempty"`
	Message    *UUID          `json:"message,omitempty"`
	TX         TransactionRef `json:"tx,omitempty"`
}

type TokenType

type TokenType = FFEnum
var (
	TokenTypeFungible    TokenType = ffEnum("tokentype", "fungible")
	TokenTypeNonFungible TokenType = ffEnum("tokentype", "nonfungible")
)

type Transaction

type Transaction struct {
	ID         *UUID              `json:"id,omitempty"`
	Hash       *Bytes32           `json:"hash"`
	Subject    TransactionSubject `json:"subject"`
	Created    *FFTime            `json:"created"`
	Status     OpStatus           `json:"status"`
	ProtocolID string             `json:"protocolId,omitempty"`
	Info       JSONObject         `json:"info,omitempty"`
}

Transaction represents (blockchain) transactions that were submitted by this node, with the correlation information to look them up on the underlying ledger technology

type TransactionRef

type TransactionRef struct {
	Type TransactionType `json:"type"`
	ID   *UUID           `json:"id,omitempty"`
}

TransactionRef refers to a transaction, in other types

type TransactionSubject

type TransactionSubject struct {
	Signer    string          `json:"signer"` // on-chain signing identity
	Namespace string          `json:"namespace,omitempty"`
	Type      TransactionType `json:"type" ffenum:"txtype"`
	Reference *UUID           `json:"reference,omitempty"`
}

TransactionSubject is the hashable reason for the transaction was performed

func (*TransactionSubject) Hash

func (t *TransactionSubject) Hash() *Bytes32

type TransactionType

type TransactionType = FFEnum
var (
	// TransactionTypeNone indicates no transaction should be used for this message/batch
	TransactionTypeNone TransactionType = ffEnum("txtype", "none")
	// TransactionTypeBatchPin represents a pinning transaction, that verifies the originator of the data, and sequences the event deterministically between parties
	TransactionTypeBatchPin TransactionType = ffEnum("txtype", "batch_pin")
	// TransactionTypeTokenPool represents a token pool creation
	TransactionTypeTokenPool TransactionType = ffEnum("txtype", "token_pool")
)

type TransportPayloadType

type TransportPayloadType = FFEnum
var (
	TransportPayloadTypeMessage TransportPayloadType = ffEnum("transportpayload", "message")
	TransportPayloadTypeBatch   TransportPayloadType = ffEnum("transportpayload", "batch")
)

type TransportWrapper

type TransportWrapper struct {
	Type    TransportPayloadType `json:"type" ffenum:"transportpayload"`
	Message *Message             `json:"message,omitempty"`
	Data    []*Data              `json:"data,omitempty"`
	Batch   *Batch               `json:"batch,omitempty"`
	Group   *Group               `json:"group,omitempty"`
}

TransportWrapper wraps paylaods over data exchange transfers, for easy deserialization at target

type UUID

type UUID uuid.UUID

UUID is a wrapper on a UUID implementation, ensuring Value handles nil

func MustParseUUID

func MustParseUUID(uuidStr string) *UUID

func NewUUID

func NewUUID() *UUID

func ParseUUID

func ParseUUID(ctx context.Context, uuidStr string) (*UUID, error)

func (*UUID) Equals

func (u *UUID) Equals(u2 *UUID) bool

func (UUID) MarshalBinary

func (u UUID) MarshalBinary() ([]byte, error)

func (UUID) MarshalText

func (u UUID) MarshalText() ([]byte, error)

func (*UUID) Scan

func (u *UUID) Scan(src interface{}) error

func (*UUID) String

func (u *UUID) String() string

func (*UUID) UnmarshalBinary

func (u *UUID) UnmarshalBinary(b []byte) error

func (*UUID) UnmarshalText

func (u *UUID) UnmarshalText(b []byte) error

func (*UUID) Value

func (u *UUID) Value() (driver.Value, error)

type ValidatorType

type ValidatorType = FFEnum
var (
	// ValidatorTypeJSON is the validator type for JSON Schema validation
	ValidatorTypeJSON ValidatorType = ffEnum("validatortype", "json")
	// ValidatorTypeSystemDefinition is the validator type for system definitions
	ValidatorTypeSystemDefinition ValidatorType = ffEnum("validatortype", "definition")
)

type WSChangeNotification

type WSChangeNotification struct {
	WSClientActionBase

	ChangeEvent *ChangeEvent `json:"change"`
}

WSChangeNotification is a special notification type for a change event, that does *not* require an ack

type WSClientActionAckPayload

type WSClientActionAckPayload struct {
	WSClientActionBase

	ID           *UUID            `json:"id,omitempty"`
	Subscription *SubscriptionRef `json:"subscription,omitempty"`
}

WSClientActionAckPayload acknowldges a received event (not applicable in AutoAck mode)

type WSClientActionBase

type WSClientActionBase struct {
	Type WSClientPayloadType `json:"type,omitempty"`
}

WSClientActionBase is the base fields of all client actions sent on the websocket

type WSClientActionStartPayload

type WSClientActionStartPayload struct {
	WSClientActionBase

	AutoAck      *bool               `json:"autoack"`
	Namespace    string              `json:"namespace"`
	Name         string              `json:"name"`
	Ephemeral    bool                `json:"ephemeral"`
	Filter       SubscriptionFilter  `json:"filter"`
	Options      SubscriptionOptions `json:"options"`
	ChangeEvents string              `json:"changeEvents,omitempty"`
}

WSClientActionStartPayload starts a subscription on this socket - either an existing one, or creating an ephemeral one

type WSClientPayloadType

type WSClientPayloadType = FFEnum

WSClientPayloadType actions go from client->server

var (
	// WSClientActionStart is a request to the server to start delivering messages to the client
	WSClientActionStart WSClientPayloadType = ffEnum("wstype", "start")
	// WSClientActionAck acknowledges an event that was delivered, allowing further messages to be sent
	WSClientActionAck WSClientPayloadType = ffEnum("wstype", "ack")

	// WSProtocolErrorEventType is a special event "type" field for server to send the client, if it performs a ProtocolError
	WSProtocolErrorEventType WSClientPayloadType = ffEnum("wstype", "protocol_error")

	// WSClientActionChangeNotifcation a special event type that is a local database change event, and never requires an ack
	WSClientActionChangeNotifcation WSClientPayloadType = ffEnum("wstype", "change_notification")
)

type WSProtocolErrorPayload

type WSProtocolErrorPayload struct {
	Type  WSClientPayloadType `json:"type" ffenum:"wstype"`
	Error string              `json:"error"`
}

WSProtocolErrorPayload is sent to the client by the server in the case of a protocol error

Jump to

Keyboard shortcuts

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