bulletprooftxmanager

package
v0.0.0-...-e348512 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCouldNotGetReceipt is the error string we save if we reach our finality depth for a confirmed transaction without ever getting a receipt
	// This most likely happened because an external wallet used the account for this nonce
	ErrCouldNotGetReceipt = "could not get receipt"
)

Functions

func BumpGas

func BumpGas(config orm.ConfigReader, originalGasPrice *big.Int) (*big.Int, error)

BumpGas computes the next gas price to attempt as the largest of: - A configured percentage bump (ETH_GAS_BUMP_PERCENT) on top of the baseline price. - A configured fixed amount of Wei (ETH_GAS_PRICE_WEI) on top of the baseline price. The baseline price is the maximum of the previous gas price attempt and the node's current gas price.

func FindEthTxsRequiringNewAttempt

func FindEthTxsRequiringNewAttempt(db *gorm.DB, address gethCommon.Address, blockNum, gasBumpThreshold, depth int64) (etxs []models.EthTx, err error)

FindEthTxsRequiringNewAttempt returns transactions that have all attempts which are unconfirmed for at least gasBumpThreshold blocks, limited by limit pending transactions

func GetNextNonce

func GetNextNonce(db *gorm.DB, address gethCommon.Address) (*int64, error)

GetNextNonce returns keys.next_nonce for the given address

func IncrementNextNonce

func IncrementNextNonce(db *gorm.DB, address gethCommon.Address, currentNonce int64) error

IncrementNextNonce increments keys.next_nonce by 1

func NewEthConfirmer

func NewEthConfirmer(store *store.Store, config orm.ConfigReader) *ethConfirmer

func SendEther

func SendEther(s *strpkg.Store, from, to gethCommon.Address, value assets.Eth) (etx models.EthTx, err error)

SendEther creates a transaction that transfers the given value of ether

Types

type EthBroadcaster

type EthBroadcaster interface {
	Start() error
	Stop() error

	Trigger()

	ProcessUnstartedEthTxs(models.Key) error
}

EthBroadcaster monitors eth_txes for transactions that need to be broadcast, assigns nonces and ensures that at least one eth node somewhere has received the transaction successfully.

This does not guarantee delivery! A whole host of other things can subsequently go wrong such as transactions being evicted from the mempool, eth nodes going offline etc. Responsibility for ensuring eventual inclusion into the chain falls on the shoulders of the ethConfirmer.

What ethBroadcaster does guarantee is: - a monotonic series of increasing nonces for eth_txes that can all eventually be confirmed if you retry enough times - transition of eth_txes out of unstarted into either fatal_error or unconfirmed - existence of a saved eth_tx_attempt

func NewEthBroadcaster

func NewEthBroadcaster(store *store.Store, config orm.ConfigReader, eventBroadcaster postgres.EventBroadcaster) EthBroadcaster

NewEthBroadcaster returns a new concrete ethBroadcaster

Jump to

Keyboard shortcuts

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