Documentation ¶
Index ¶
- Constants
- Variables
- func ReadAddr(db ethdb.Reader, i uint64) common.Address
- func ReadAddrNonce(db ethdb.Reader, addr common.Address) uint64
- func ReadGasPrice(db ethdb.Reader) *big.Int
- func ReadNumAddr(db ethdb.Reader) uint64
- func ReadNumConfirmedRawTxs(db ethdb.Reader, addr common.Address) uint64
- func ReadNumRawTxs(db ethdb.Reader, addr common.Address) uint64
- func WriteAddr(db ethdb.KeyValueWriter, i uint64, addr common.Address)
- func WriteAddrNonce(db ethdb.KeyValueWriter, addr common.Address, nonce uint64)
- func WriteConfirmedTx(db ethdb.KeyValueWriter, addr common.Address, i uint64, raw *RawTransaction)
- func WriteGasPrice(db ethdb.KeyValueWriter, gasPrice *big.Int)
- func WriteNumAddr(db ethdb.KeyValueWriter, n uint64)
- func WriteNumConfirmedRawTxs(db ethdb.KeyValueWriter, addr common.Address, n uint64)
- func WriteNumRawTxs(db ethdb.KeyValueWriter, addr common.Address, n uint64)
- func WritePendingTxs(db ethdb.KeyValueWriter, addr common.Address, txs RawTransactions)
- func WriteRawTxHash(db ethdb.KeyValueWriter, addr common.Address, raw RawTransaction)
- func WriteUnconfirmedTxs(db ethdb.KeyValueWriter, addr common.Address, txs RawTransactions)
- type Config
- type RawTransaction
- func NewRawTransaction(from common.Address, gasLimit uint64, receipt *common.Address, amount *big.Int, ...) *RawTransaction
- func ReadConfirmedTx(db ethdb.Reader, addr common.Address, i uint64) *RawTransaction
- func ReadRawTxHash(db ethdb.Reader, addr common.Address, rawHash common.Hash) *RawTransaction
- func (raw *RawTransaction) AddPending(tx *types.Transaction) error
- func (raw *RawTransaction) CheckMined(backend *ethclient.Client, force bool) (mined bool, err error)
- func (raw *RawTransaction) Confirmed(backend *ethclient.Client, currentBlockNumber *big.Int) bool
- func (raw *RawTransaction) Equal(tx *types.Transaction, chainId *big.Int) bool
- func (raw *RawTransaction) HasPending(tx *types.Transaction) bool
- func (raw *RawTransaction) Hash() common.Hash
- func (raw *RawTransaction) Mined(backend *ethclient.Client) bool
- func (raw *RawTransaction) PrepareToResend()
- func (raw *RawTransaction) Removed(backend *ethclient.Client) (removed bool, err error)
- func (raw *RawTransaction) ToTransaction(gasPrice *big.Int) *types.Transaction
- type RawTransactions
- type RawTransactionsByIndex
- type TransactionManager
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 ReadNumAddr ¶
func ReadNumConfirmedRawTxs ¶
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 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 ReadConfirmedTx ¶
func ReadRawTxHash ¶
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) 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) 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 (*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()
Click to show internal directories.
Click to hide internal directories.