tx

package
v0.0.0-rc7.7 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNumTask    = 500
	MaxNumKnownTx = 5
	SendDelay     = 2

	// TODO: make below configurable
	Confirmation      = 32
	ConfirmationDelay = 4
)
View Source
const (
	MaxNumPending = 128 // The maximum number of transactions that a raw transaction can have.
)
View Source
const (
	MaxUint64 = math.MaxUint64
)

Variables

View Source
var (
	ErrLockedAccount    = errors.New("account is locked")
	ErrUnknownAccount   = errors.New("account not found in keystore")
	ErrKnownTransaction = errors.New("known transaction")
	ErrDuplicateRaw     = errors.New("duplicate raw transaction")
	ErrNoDuplicateRaw   = errors.New("there is no duplicate raw transaction")
)
View Source
var DefaultConfig = &Config{
	GasPrice:    new(big.Int).SetInt64(10 * params.GWei),
	MinGasPrice: new(big.Int).SetInt64(1 * params.GWei),
	MaxGasPrice: new(big.Int).SetInt64(100 * params.GWei),
	Interval:    10 * time.Second,
	ChainId:     new(big.Int).SetInt64(1),
}
View Source
var (
	ErrTooManyPending = errors.New("Too many pending transactions")
)

Functions

func ReadAddr

func ReadAddr(db ethdb.Reader, i uint64) common.Address

func ReadAddrNonce

func ReadAddrNonce(db ethdb.Reader, addr common.Address) uint64

func ReadGasPrice

func ReadGasPrice(db ethdb.Reader) *big.Int

func ReadNumAddr

func ReadNumAddr(db ethdb.Reader) uint64

func ReadNumConfirmedRawTxs

func ReadNumConfirmedRawTxs(db ethdb.Reader, addr common.Address) uint64

func ReadNumRawTxs

func ReadNumRawTxs(db ethdb.Reader, addr common.Address) uint64

func WriteAddr

func WriteAddr(db ethdb.KeyValueWriter, i uint64, addr common.Address)

func WriteAddrNonce

func WriteAddrNonce(db ethdb.KeyValueWriter, addr common.Address, nonce uint64)

func WriteConfirmedTx

func WriteConfirmedTx(db ethdb.KeyValueWriter, addr common.Address, i uint64, raw *RawTransaction)

func WriteGasPrice

func WriteGasPrice(db ethdb.KeyValueWriter, gasPrice *big.Int)

func WriteNumAddr

func WriteNumAddr(db ethdb.KeyValueWriter, n uint64)

func WriteNumConfirmedRawTxs

func WriteNumConfirmedRawTxs(db ethdb.KeyValueWriter, addr common.Address, n uint64)

func WriteNumRawTxs

func WriteNumRawTxs(db ethdb.KeyValueWriter, addr common.Address, n uint64)

func WritePendingTxs

func WritePendingTxs(db ethdb.KeyValueWriter, addr common.Address, txs RawTransactions)

func WriteRawTxHash

func WriteRawTxHash(db ethdb.KeyValueWriter, addr common.Address, raw RawTransaction)

func WriteUnconfirmedTxs

func WriteUnconfirmedTxs(db ethdb.KeyValueWriter, addr common.Address, txs RawTransactions)

Types

type Config

type Config struct {
	GasPrice    *big.Int
	MinGasPrice *big.Int
	MaxGasPrice *big.Int
	ChainId     *big.Int
	Interval    time.Duration
}

type RawTransaction

type RawTransaction struct {
	Index               uint64
	ConfirmedIndex      uint64
	ResendCount         uint64
	LastSentBlockNumber uint64

	// transaction field
	Nonce     *big.Int
	From      common.Address
	GasLimit  uint64
	Recipient *common.Address
	Amount    *big.Int
	Payload   []byte

	AllowRevert bool

	PendingTxs       types.Transactions
	MinedTxHash      common.Hash
	MinedBlockNumber *big.Int
	Reverted         bool

	Caption string
	// contains filtered or unexported fields
}

(nonce, price) is set by TransactionManager. RawTransaction represents metadata for ethereum transaction. A RawTransaction with nonce and gas price is signed and sent to ethereum JSONRPC server, and it is stored in PendingTxs. PendingTxs is checked if it is mined and confirmed. Unconfirmed and mined pending transactions

func NewRawTransaction

func NewRawTransaction(from common.Address, gasLimit uint64, receipt *common.Address, amount *big.Int, payload []byte, allowRevert bool, caption string) *RawTransaction

func ReadConfirmedTx

func ReadConfirmedTx(db ethdb.Reader, addr common.Address, i uint64) *RawTransaction

func ReadRawTxHash

func ReadRawTxHash(db ethdb.Reader, addr common.Address, rawHash common.Hash) *RawTransaction

func (*RawTransaction) AddPending

func (raw *RawTransaction) AddPending(tx *types.Transaction) error

func (*RawTransaction) CheckMined

func (raw *RawTransaction) CheckMined(backend *ethclient.Client, force bool) (mined bool, err error)

CheckMined clears all pending transactions and sets mined transaction hash if transaction is mined .

func (*RawTransaction) Confirmed

func (raw *RawTransaction) Confirmed(backend *ethclient.Client, currentBlockNumber *big.Int) bool

func (*RawTransaction) Equal

func (raw *RawTransaction) Equal(tx *types.Transaction, chainId *big.Int) bool

func (*RawTransaction) HasPending

func (raw *RawTransaction) HasPending(tx *types.Transaction) bool

func (*RawTransaction) Hash

func (raw *RawTransaction) Hash() common.Hash

func (*RawTransaction) Mined

func (raw *RawTransaction) Mined(backend *ethclient.Client) bool

func (*RawTransaction) PrepareToResend

func (raw *RawTransaction) PrepareToResend()

func (*RawTransaction) Removed

func (raw *RawTransaction) Removed(backend *ethclient.Client) (removed bool, err error)

Removed returns whether the mined transaction is removed from ethereum blockchain.

func (*RawTransaction) ToTransaction

func (raw *RawTransaction) ToTransaction(gasPrice *big.Int) *types.Transaction

type RawTransactions

type RawTransactions []*RawTransaction

func ReadPendingTxs

func ReadPendingTxs(db ethdb.Reader, addr common.Address) RawTransactions

func ReadUnconfirmedTxs

func ReadUnconfirmedTxs(db ethdb.Reader, addr common.Address) RawTransactions

type RawTransactionsByIndex

type RawTransactionsByIndex RawTransactions

func (RawTransactionsByIndex) Len

func (r RawTransactionsByIndex) Len() int

func (RawTransactionsByIndex) Less

func (r RawTransactionsByIndex) Less(i, j int) bool

func (RawTransactionsByIndex) Swap

func (r RawTransactionsByIndex) Swap(i, j int)

type TransactionManager

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

TODO: Add JSONRPC API for TransactionManager

func NewTransactionManager

func NewTransactionManager(ks *keystore.KeyStore, backend *ethclient.Client, db ethdb.Database, config *Config) (*TransactionManager, error)

func (*TransactionManager) Add

func (tm *TransactionManager) Add(account accounts.Account, raw *RawTransaction, duplicate bool) error

Add adds raw transaction to confirmed.

func (*TransactionManager) Count

func (tm *TransactionManager) Count(account accounts.Account, tx *types.Transaction) uint64

TODO: rename to Has Count returns the number of raw transactions corresponding to the transaction.

func (*TransactionManager) Start

func (tm *TransactionManager) Start()

func (*TransactionManager) Stop

func (tm *TransactionManager) Stop()

Jump to

Keyboard shortcuts

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