Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int64) int64
- func BigFloatToHumanNumberString(f *big.Float, decimals int) string
- func BigIntToHumanNumberString(i *big.Int, decimals int) string
- func ColorPrintf(color string, format string, a ...interface{})
- func DateToTime(dayString string, hour int, min int, sec int) (time.Time, error)
- func EstimateTargetBlocknumber(utcTimestamp int64) int64
- func FindBlockRange(client *ethclient.Client, blockHeight int, date string, hour int, min int, ...) (startBlock int64, endBlock int64, err error)
- func GetBlocks(blockChan chan<- *types.Block, client *ethclient.Client, startBlock int64, ...)
- func GetErc20TokensInUnit(numTokens *big.Int, addrDetail addressdetail.AddressDetail) (amount *big.Float, symbol string)
- func GetFirstBlockHeaderAtOrAfterTime(client *ethclient.Client, targetTime time.Time) (header *types.Header, err error)
- func GetTxSender(tx *types.Transaction) (from common.Address, err error)
- func IsBigIntZero(n *big.Int) bool
- func NumberToHumanReadableString(value interface{}, decimals int) string
- func Perror(err error)
- func PrintBlock(block *types.Block)
- func WeiBigIntToEthString(wei *big.Int, decimals int) string
- func WeiToEth(wei *big.Int) (ethValue *big.Float)
- func WeiUintToEth(wei uint64) (ethValue float64)
Constants ¶
const ( InfoColor = "\033[1;34m%s\033[0m" NoticeColor = "\033[1;36m%s\033[0m" WarningColor = "\033[1;33m%s\033[0m" ErrorColor = "\033[1;31m%s\033[0m" DebugColor = "\033[0;36m%s\033[0m" )
Variables ¶
var DebugEnabled bool = os.Getenv("DEBUG") != ""
var (
ErrTargetTimestampAfterLatestBlock = errors.New("target timestamp after latest block")
)
Functions ¶
func ColorPrintf ¶
func EstimateTargetBlocknumber ¶
Roughly estimate a block number by target timestamp (might be off by a lot)
func FindBlockRange ¶ added in v0.3.0
func FindBlockRange(client *ethclient.Client, blockHeight int, date string, hour int, min int, length string) (startBlock int64, endBlock int64, err error)
GetBlockRangeFromArguments returns start and end blocks for a given block or date range. startBlock is first block at or after the given time, endBlock is the last before the given end time.
func GetBlocks ¶ added in v0.5.2
func GetBlocks(blockChan chan<- *types.Block, client *ethclient.Client, startBlock int64, endBlock int64, concurrency int)
GetBlocks is a fast block query pipeline. It queries blocks concurrently and pushes it into a channel for processing.
func GetErc20TokensInUnit ¶ added in v0.3.3
func GetErc20TokensInUnit(numTokens *big.Int, addrDetail addressdetail.AddressDetail) (amount *big.Float, symbol string)
func GetFirstBlockHeaderAtOrAfterTime ¶
func GetFirstBlockHeaderAtOrAfterTime(client *ethclient.Client, targetTime time.Time) (header *types.Header, err error)
GetBlockHeaderAtTimestamp returns the header of the first block at or after the timestamp. If timestamp is after latest block, then return latest block. This function is a bit messy, but works. Improvements to this approach are welcome.
func GetTxSender ¶
func GetTxSender(tx *types.Transaction) (from common.Address, err error)
func IsBigIntZero ¶
func PrintBlock ¶
func WeiBigIntToEthString ¶ added in v0.3.2
// Returns bigint wei amount as comma-separated, human-readable string (eg. 1,435,332.71)
func WeiUintToEth ¶ added in v0.3.2
Types ¶
This section is empty.