txstream

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0, BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagClientToServer is set in a message type if the message is client to server
	FlagClientToServer = byte(0x80)
	// FlagServerToClient is set in a message type if the message is server to client
	FlagServerToClient = byte(0x40)
)
View Source
const ChunkMessageHeaderSize = 3

ChunkMessageHeaderSize is the amount of bytes added by MsgChunk as overhead to each chunk

Variables

This section is empty.

Functions

func DecodeMsg

func DecodeMsg(data []byte, expectedFlags uint8) (interface{}, error)

DecodeMsg decodes a Message from the given bytes

func EncodeMsg

func EncodeMsg(msg Message) []byte

EncodeMsg encodes the given Message as a byte slice

Types

type Ledger

type Ledger interface {
	GetUnspentOutputs(addr ledgerstate.Address, f func(ledgerstate.Output))
	GetOutput(outID ledgerstate.OutputID, f func(ledgerstate.Output)) bool
	GetOutputMetadata(outID ledgerstate.OutputID, f func(*ledgerstate.OutputMetadata)) bool
	GetConfirmedTransaction(txid ledgerstate.TransactionID, f func(*ledgerstate.Transaction)) bool
	GetTxInclusionState(txid ledgerstate.TransactionID) (ledgerstate.InclusionState, error)
	EventTransactionConfirmed() *events.Event
	EventTransactionBooked() *events.Event
	PostTransaction(tx *ledgerstate.Transaction) error
	Detach()
}

Ledger is the interface between txstream and the underlying value tangle

type Message

type Message interface {
	Write(w *marshalutil.MarshalUtil)
	Read(r *marshalutil.MarshalUtil) error
	Type() MessageType
}

Message is the common interface of all messages in the txstream protocol

type MessageType

type MessageType byte

MessageType represents the type of a message in the txstream protocol

type MsgChunk

type MsgChunk struct {
	Data []byte
}

MsgChunk is a special message for big data packets chopped into pieces

func (*MsgChunk) Read

func (msg *MsgChunk) Read(m *marshalutil.MarshalUtil) error

func (*MsgChunk) Type

func (msg *MsgChunk) Type() MessageType

Type returns the Message type

func (*MsgChunk) Write

func (msg *MsgChunk) Write(w *marshalutil.MarshalUtil)

type MsgGetBacklog

type MsgGetBacklog struct {
	Address ledgerstate.Address
}

MsgGetBacklog is a request to get the backlog for the given address. Server replies sending one MsgTransaction for each transaction with unspent outputs targeted to the address.

func (*MsgGetBacklog) Read

func (*MsgGetBacklog) Type

func (msg *MsgGetBacklog) Type() MessageType

Type returns the Message type

func (*MsgGetBacklog) Write

func (msg *MsgGetBacklog) Write(w *marshalutil.MarshalUtil)

type MsgGetConfirmedOutput

type MsgGetConfirmedOutput struct {
	Address  ledgerstate.Address
	OutputID ledgerstate.OutputID
}

MsgGetConfirmedOutput is a request to get a specific confirmed output from the ledger. It may or may not be consumed

func (*MsgGetConfirmedOutput) Read

func (*MsgGetConfirmedOutput) Type

func (msg *MsgGetConfirmedOutput) Type() MessageType

Type returns the Message type

func (*MsgGetConfirmedOutput) Write

type MsgGetConfirmedTransaction

type MsgGetConfirmedTransaction struct {
	Address ledgerstate.Address
	TxID    ledgerstate.TransactionID
}

MsgGetConfirmedTransaction is a request to get a specific confirmed transaction from the ledger. Server replies with MsgTransaction.

func (*MsgGetConfirmedTransaction) Read

func (*MsgGetConfirmedTransaction) Type

Type returns the Message type

func (*MsgGetConfirmedTransaction) Write

type MsgGetTxInclusionState

type MsgGetTxInclusionState struct {
	Address ledgerstate.Address
	TxID    ledgerstate.TransactionID
}

MsgGetTxInclusionState is a request to get the inclusion state for a transaction. Server replies with MsgTxInclusionState.

func (*MsgGetTxInclusionState) Read

func (*MsgGetTxInclusionState) Type

func (msg *MsgGetTxInclusionState) Type() MessageType

Type returns the Message type

func (*MsgGetTxInclusionState) Write

type MsgGetUnspentAliasOutput

type MsgGetUnspentAliasOutput struct {
	AliasAddress *ledgerstate.AliasAddress
}

MsgGetUnspentAliasOutput is a request to get the unique unspent AliasOutput for the given AliasAddress.

func (*MsgGetUnspentAliasOutput) Read

func (*MsgGetUnspentAliasOutput) Type

Type returns the Message type

func (*MsgGetUnspentAliasOutput) Write

type MsgOutput

type MsgOutput struct {
	Address        ledgerstate.Address
	Output         ledgerstate.Output
	OutputMetadata *ledgerstate.OutputMetadata
}

MsgOutput is the response for MsgGetConfirmedOutput

func (*MsgOutput) Read

func (msg *MsgOutput) Read(m *marshalutil.MarshalUtil) error

func (*MsgOutput) Type

func (msg *MsgOutput) Type() MessageType

Type returns the Message type

func (*MsgOutput) Write

func (msg *MsgOutput) Write(w *marshalutil.MarshalUtil)

type MsgPostTransaction

type MsgPostTransaction struct {
	Tx *ledgerstate.Transaction
}

MsgPostTransaction is a request from the client to post a transaction in the ledger. No reply from server.

func (*MsgPostTransaction) Read

func (*MsgPostTransaction) Type

func (msg *MsgPostTransaction) Type() MessageType

Type returns the Message type

func (*MsgPostTransaction) Write

type MsgSetID

type MsgSetID struct {
	ClientID string
}

MsgSetID is a message from client informing its ID, used mostly for tracing/loging.

func (*MsgSetID) Read

func (msg *MsgSetID) Read(m *marshalutil.MarshalUtil) error

func (*MsgSetID) Type

func (msg *MsgSetID) Type() MessageType

Type returns the Message type

func (*MsgSetID) Write

func (msg *MsgSetID) Write(w *marshalutil.MarshalUtil)

type MsgTransaction

type MsgTransaction struct {
	// Address is the address that requested the transaction
	Address ledgerstate.Address
	// Tx is the transaction being sent
	Tx *ledgerstate.Transaction
}

MsgTransaction informs the client of a given confirmed transaction in the ledger.

func (*MsgTransaction) Read

func (*MsgTransaction) Type

func (msg *MsgTransaction) Type() MessageType

Type returns the Message type

func (*MsgTransaction) Write

func (msg *MsgTransaction) Write(w *marshalutil.MarshalUtil)

type MsgTxInclusionState

type MsgTxInclusionState struct {
	Address ledgerstate.Address
	TxID    ledgerstate.TransactionID
	State   ledgerstate.InclusionState
}

MsgTxInclusionState informs the client with the inclusion state of a given transaction as a response from the given address.

func (*MsgTxInclusionState) Read

func (*MsgTxInclusionState) Type

func (msg *MsgTxInclusionState) Type() MessageType

Type returns the Message type

func (*MsgTxInclusionState) Write

type MsgUnspentAliasOutput

type MsgUnspentAliasOutput struct {
	AliasAddress   *ledgerstate.AliasAddress
	AliasOutput    *ledgerstate.AliasOutput
	OutputMetadata *ledgerstate.OutputMetadata
	Timestamp      time.Time
}

MsgUnspentAliasOutput is the response for MsgGetUnspentAliasOutput

func (*MsgUnspentAliasOutput) Read

func (*MsgUnspentAliasOutput) Type

func (msg *MsgUnspentAliasOutput) Type() MessageType

Type returns the Message type

func (*MsgUnspentAliasOutput) Write

type MsgUpdateSubscriptions

type MsgUpdateSubscriptions struct {
	Addresses []ledgerstate.Address
}

MsgUpdateSubscriptions is a request from the client to subscribe to requests/transactions for the given addresses. Server will send all transactions containing unspent outputs to the address, and then whenever a relevant transaction is confirmed in the ledger, i will be sent in real-time.

func (*MsgUpdateSubscriptions) Read

func (*MsgUpdateSubscriptions) Type

func (msg *MsgUpdateSubscriptions) Type() MessageType

Type returns the Message type

func (*MsgUpdateSubscriptions) Write

Directories

Path Synopsis
Package chopper helps splitting messages into smaller pieces and reassemble them
Package chopper helps splitting messages into smaller pieces and reassemble them

Jump to

Keyboard shortcuts

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