txnmanager

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendResponse

func SendResponse(w http.ResponseWriter, response any) error

SendResponse sends a response to the client.

Types

type Manager

type Manager interface {
	// GET /transactions/{token}
	StatusHandlerGet(http.ResponseWriter, *http.Request)

	// submit the transaction to the blockchain
	// return the transactionID and
	// the index of the last block when it was submitted
	SubmitTxn(ctx context.Context, cmd evoting.Command, cmdArg string, payload []byte) ([]byte, uint64, error)

	// CreateTransactionResult create the json to send to the client
	CreateTransactionResult(txnID []byte, lastBlockIdx uint64, status TransactionStatus) (TransactionClientInfo, error)
	SendTransactionInfo(w http.ResponseWriter, txnID []byte, lastBlockIdx uint64, status TransactionStatus) error
}

Manager defines the public HTTP API of the transaction manager

func NewTransactionManager

func NewTransactionManager(mngr txn.Manager, p pool.Pool,
	ctx serde.Context, pk kyber.Point, blocks blockstore.BlockStore, signer crypto.Signer) Manager

NewTransactionManager returns a new initialized transaction manager

type TransactionClientInfo

type TransactionClientInfo struct {
	Status TransactionStatus // 0 if not yet included, 1 if included, 2 if rejected
	Token  string
}

TransactionClientInfo defines the HTTP response when sending transaction infos to the client so that he can use the status of the transaction to know if it has been included or not and if it has not been included, he can just use the token and ask again later

type TransactionStatus

type TransactionStatus byte

TransactionStatus is the status of a transaction

const (
	// UnknownTransactionStatus is the basic status of a transaction
	UnknownTransactionStatus TransactionStatus = 0
	// IncludedTransaction is the status of a transaction that has been included
	IncludedTransaction TransactionStatus = 1
	// RejectedTransaction is the status of a transaction will never be included
	RejectedTransaction TransactionStatus = 2
)

Jump to

Keyboard shortcuts

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