 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
const CName = "any-ns.nonce-manager"
    Variables ¶
This section is empty.
Functions ¶
Types ¶
type NonceDbItem ¶
TODO: index it
type NonceService ¶
type NonceService interface {
	// try to determine nonce by looking in DB first, then use network as a fallback
	GetCurrentNonce(addr ethcommon.Address) (uint64, error)
	// try to determine nonce by looking at current TX count plus pending TXs in the mem pool
	// (not reliable, but can be used as a fallback)
	GetCurrentNonceFromNetwork(addr ethcommon.Address) (uint64, error)
	// save nonce to DB
	SaveNonce(addr ethcommon.Address, newValue uint64) (uint64, error)
	app.Component
}
    Nonce policy: 1. if nonce is specified in the config file: - read it from config and override the value from DB/network
2. if nonce is in DB: - get nonce from DB
3. if nonce is not in DB: - get nonce from network - mined + pending txs count
if tx is sent and mined succesfully: - save last nonce to DB
if we got "nonce is too low" error the tx is immediately rejected. to fix it: - get nonce from network - send this tx again with +1 nonce
if nonce is higher than needed - tx will be rejected by the network with "not found" error immediately in this case we: - wait for N minutes for all TXs to settle - get new nonce from network - retry sending this tx with new nonce