tx

package
v0.0.0-...-9098a98 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package tx defines the data structures and methods to manage pending transactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotExist    = errors.New("account not exist")
	ErrInsufficientForFee = errors.New("insufficient balance for fee")
	ErrInsufficientForTx  = errors.New("insufficient balance for tx")
	ErrInvalidSeqNum      = errors.New("invalid sequence number")
	ErrInvalidOpType      = errors.New("invalid op type")
)
View Source
var (
	// Maximum number of operations in a transactions.
	MaxTxOpList = int(100)
	// Maximum length of note in a transaction.
	MaxTxNote = int(128)
)

Functions

func ValidateManagerContext

func ValidateManagerContext(mc *ManagerContext) error

Types

type Manager

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

Manager manages incoming tx and coordinates with ledger manager and consensus engine.

func NewManager

func NewManager(ctx *ManagerContext) *Manager

NewManager creates an instance of Manager with TxManagerContext.

func (*Manager) AddTx

func (tm *Manager) AddTx(txKey string, tx *ultpb.Tx) error

Add transaction to internal pending set.

func (*Manager) ApplyTxList

func (tm *Manager) ApplyTxList(txList []*ultpb.Tx, ledgerSeqNum uint64) error

Apply the tx list by charging fees and applying all the ops.

func (*Manager) DeleteTxList

func (tm *Manager) DeleteTxList(txList []*ultpb.Tx)

Delete tx list from the manager and update internal fields.

func (*Manager) GetTxList

func (tm *Manager) GetTxList() []*ultpb.Tx

Get concatenated tx list of each account.

func (*Manager) GetTxStatus

func (tm *Manager) GetTxStatus(txKey string) (*rpcpb.TxStatus, error)

Get the status of tx.

func (*Manager) Start

func (tm *Manager) Start()

Start the internal event loop for tx manager.

func (*Manager) Stop

func (tm *Manager) Stop()

Stop tx manager by closing stopChan to notify goroutines to stop.

func (*Manager) UpdateTxStatus

func (tm *Manager) UpdateTxStatus(txKey string, status *rpcpb.TxStatus) error

Update the status of tx.

type ManagerContext

type ManagerContext struct {
	NetworkID   string
	Database    db.Database
	AM          *account.Manager
	PM          *peer.Manager
	EM          *exchange.Manager
	BaseReserve int64
	Seed        string
}

ManagerContext represents contextual information TxManager needs.

type TxHistory

type TxHistory struct {
	// Maximum sequence number of the tx list.
	MaxSeqNum uint64
	// Total fees of the tx list.
	TotalFees int64
	// contains filtered or unexported fields
}

TxHistory is used to hold unconfirmed transactions.

func NewTxHistory

func NewTxHistory() *TxHistory

func (*TxHistory) AddTx

func (th *TxHistory) AddTx(txKey string, tx *ultpb.Tx) error

AddTx adds a transaction to pending list, note that before adding any transaction, it should be checked against signature correctness, sufficient balance of account, etc.

func (*TxHistory) DeleteTxList

func (th *TxHistory) DeleteTxList(txKeys []string)

Delete transactions and update fields.

func (*TxHistory) GetTxList

func (th *TxHistory) GetTxList() []*ultpb.Tx

Get the flattened tx list.

func (*TxHistory) Size

func (th *TxHistory) Size() int

Get the size of internal tx map.

type TxSlice

type TxSlice []*ultpb.Tx

Custom tx sort by sequence number.

func (TxSlice) Len

func (ts TxSlice) Len() int

func (TxSlice) Less

func (ts TxSlice) Less(i, j int) bool

func (TxSlice) Swap

func (ts TxSlice) Swap(i, j int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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