client

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {

	// NewTX creates and returns a new transaction of type txType, containing data.
	// The returned transaction will be assigned the next transaction number in sequence,
	// corresponding to the number of transactions previously created by this client.
	// Until Done is called with the returned transaction's number,
	// the transaction will be pending, i.e., among the transactions returned by Pending.
	// The transaction need not necessarily yet be written to persistent storage when NewTX returns.
	// Use the separate Sync() method to guarantee persistence.
	NewTX(txType uint64, data []byte) (*trantorpbtypes.Transaction, error)

	// Done marks a transaction as done. It will no longer be among the transactions returned by Pending.
	// The effect of this call need not be written to persistent storage until Sync is called.
	Done(txNo tt.TxNo) error

	// Pending returns all transactions previously returned by NewTX that have not been marked as done.
	Pending() ([]*trantorpbtypes.Transaction, error)

	// Sync ensures that the effects of all previous calls to NewTX and Done have been written to persistent storage.
	Sync() error
}

The Client represents an SMR client that produces new transactions (using NewTX) that can be submitted to the SMR system. It sequentially assigns transaction numbers to all created transactions. The Client is informed (using Done) when a transaction is considered applied (or otherwise safe to stop caring about). All created transactions that have not been confirmed this way are considered pending. The client is expected to persistently store all pending transactions, in case they need to be resubmitted after recovering from a potential crash.

type VolatileClient

type VolatileClient struct {
	// contains filtered or unexported fields
}

VolatileClient is a simple implementation of the SMR Client interface that does not provide any persistence. It is meant for testing purposes and for cases where the machine running it is assumed to never crash.

func NewVolatileClient

func NewVolatileClient(clientID tt.ClientID) *VolatileClient

NewVolatileClient returns a new instance of VolatileClient. All transaction it produces will be identified with the given clientID.

func (*VolatileClient) Done

func (vc *VolatileClient) Done(txNo tt.TxNo) error

Done marks a transaction as done. It will no longer be among the transactions returned by Pending.

func (*VolatileClient) NewTX

func (vc *VolatileClient) NewTX(txType uint64, data []byte) (*trantorpb.Transaction, error)

NewTX creates and returns a new transaction of type txType, containing data. The returned transaction will be assigned the next transaction number in sequence, corresponding to the number of transactions previously created by this client. Until Done is called with the returned transaction's number, the transaction will be pending, i.e., among the transactions returned by Pending.

func (*VolatileClient) Pending

func (vc *VolatileClient) Pending() ([]*trantorpb.Transaction, error)

Pending returns all transactions previously returned by NewTX that have not been marked as done.

func (*VolatileClient) Sync

func (vc *VolatileClient) Sync() error

Sync does nothing. VolatileClient does not provide any persistence.

Jump to

Keyboard shortcuts

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