Documentation ¶
Overview ¶
Package base implements various base functions
Index ¶
- Constants
- Variables
- func BiFromBn(bn Blknum) *big.Int
- func Bytes2Hex(d []byte) string
- func FormattedDate(ts Timestamp) string
- func Hex2Bytes(str string) []byte
- func IsFinal(latestTs, blockTs Timestamp) bool
- func IsHex(str string) bool
- func IsPrecompile(addr string) bool
- func IsValidAddress(val string) bool
- func IsValidAddressE(val string) (bool, error)
- func IsValidHex(typ string, val string, nBytes int) (bool, error)
- func Max[T Value | int | float64 | uint32 | int64](x, y T) T
- func Min[T Value | int | float64 | uint32 | int64](x, y T) T
- func MustParseFloat64(val string) float64
- func MustParseInt64(input string) int64
- func MustParseUint64(input string) uint64
- func ValidHex(val string, nBytes int) (bool, error)
- type Address
- func (a Address) CheckSum() string
- func (a *Address) Common() common.Address
- func (a *Address) Encoded32() string
- func (a Address) Format(s fmt.State, c rune)
- func (a *Address) Hex() string
- func (a *Address) IsZero() bool
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Pad32() string
- func (a *Address) Prefix(n int) string
- func (a *Address) SetCommon(c *common.Address) Address
- func (a *Address) SetHex(hexStr string)
- func (a Address) String() string
- func (e *Address) UnmarshalJSON(data []byte) error
- type Blknum
- type BlockRange
- type Ether
- func (e *Ether) Cmp(other *Ether) int
- func (e *Ether) Float64() float64
- func (e *Ether) MarshalJSON() ([]byte, error)
- func (e *Ether) Quo(a, b *Ether) *Ether
- func (e *Ether) SetFloat64(f float64) *Ether
- func (e *Ether) SetInt64(i int64) *Ether
- func (e *Ether) SetString(s string) (*Ether, bool)
- func (e *Ether) SetUint64(i uint64) *Ether
- func (e *Ether) SetWei(i *Wei) *Ether
- func (e *Ether) String() string
- func (x *Ether) Text(format byte, prec int) string
- func (e *Ether) UnmarshalJSON(data []byte) error
- type FileRange
- func (r *FileRange) EarlierThan(needle FileRange) bool
- func (r *FileRange) EarlierThanB(bn Blknum) bool
- func (r *FileRange) Equals(needle FileRange) bool
- func (r *FileRange) Follows(needle FileRange, sequential bool) bool
- func (r *FileRange) Intersects(needle FileRange) bool
- func (r *FileRange) IntersectsB(bn Blknum) bool
- func (r *FileRange) LaterThan(needle FileRange) bool
- func (r *FileRange) LaterThanB(bn Blknum) bool
- func (r *FileRange) Overlaps(test FileRange) (rd RangeDiff)
- func (r *FileRange) Preceeds(needle FileRange, sequential bool) bool
- func (r *FileRange) RangeToFilename(chain string) string
- func (r *FileRange) Span() Blknum
- func (r FileRange) String() string
- type Float
- type Gas
- type Hash
- func (h *Hash) Common() common.Hash
- func (h Hash) Format(s fmt.State, c rune)
- func (h *Hash) Hex() string
- func (h *Hash) IsZero() bool
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) SetCommon(c *common.Hash) Hash
- func (h *Hash) SetHex(hexStr string)
- func (h *Hash) String() string
- func (h *Hash) UnmarshalCache(version uint64, reader io.Reader) error
- func (h *Hash) UnmarshalJSON(data []byte) error
- type IpfsHash
- type Lognum
- type Pair
- type RangeDiff
- type RecordRange
- type Timestamp
- type TimestampRange
- type Topic
- type Tracenum
- type Txnum
- type Value
- type Wei
- func (w *Wei) Add(x, y *Wei) *Wei
- func (w *Wei) BigInt() *big.Int
- func (w *Wei) Bytes() []byte
- func (w *Wei) Cmp(y *Wei) int
- func (w *Wei) Div(x, y *Wei) *Wei
- func (w *Wei) Float64() float64
- func (w *Wei) IsZero() bool
- func (w *Wei) MarshalCache(writer io.Writer) error
- func (w *Wei) MarshalText() (text []byte, err error)
- func (w *Wei) Mul(x, y *Wei) *Wei
- func (w *Wei) Quo(x, y *Wei) *Wei
- func (w *Wei) SetInt64(x int64) *Wei
- func (w *Wei) SetString(s string, base int) (*Wei, bool)
- func (w *Wei) SetUint64(x uint64) *Wei
- func (w *Wei) String() string
- func (w *Wei) Sub(x, y *Wei) *Wei
- func (x *Wei) Text(base int) string
- func (w *Wei) ToEtherStr(decimals int) string
- func (b *Wei) ToInt() *big.Int
- func (w *Wei) Uint64() uint64
- func (w *Wei) UnmarshalCache(version uint64, reader io.Reader) error
- func (e *Wei) UnmarshalJSON(data []byte) error
- func (w *Wei) UnmarshalText(text []byte) error
Constants ¶
const NOPOS = uint64(^uint64(0))
const NOPOSI = Timestamp(0xdeadbeef)
const NOPOSN = Value(^uint64(0))
Variables ¶
var ( NotAMonitor = HexToAddress("0x1234deaddeaddead98766789deaddeaddead4321") SentinalAddr = HexToAddress("0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddead") ZeroAddr = HexToAddress("0x0") )
A few well-known address. ZeroAddr, of course, is 0x0. NotAMonitor is a marker to signify the end of the monitor list produced by ListMonitors. SentinalAddr is for misconfigured miner appearances
var ( PrefundSender = HexToAddress("0x0000000000000000000000000050726566756e64") // The word "Prefund" in hex BlockRewardSender = HexToAddress("0x0000000000000000000000000000004d696e6572") // The word "Miner" in hex UncleRewardSender = HexToAddress("0x000000000000000000000000000000556e636c65") // The word "Uncle" in hex WithdrawalSender = HexToAddress("0x000000000000000000005769746864726177616C") // The word "Withdrawal" in hex SkippedSender = HexToAddress("0x00000000000000000000000000536B6970706564") // The word "Skipped" in hex )
These purposefully chosen baddresses are used to indicate that the transaction is a prefund and uncle reward, or a mining reward. They are not real addresses, but are used to indicate that the transaction is not a normal transaction. They are not (currently) indexed.
var ( Byzantium = "byzantium" Constantinople = "constantinople" London = "london" Merge = "merge" Shanghai = "shanghai" FirstTrace = "first_trace" )
var ErrInvalidHex = errors.New("hex string must contain only hex characters")
var ErrInvalidLength = errors.New("hex string must be an even length")
var ErrNoLeading0x = errors.New("hex string must start with 0x")
var FAKE_ETH_ADDRESS = HexToAddress("0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")
FAKE_ETH_ADDRESS is the address we use to represent ETH in the ledgers
var NotARange = FileRange{First: NOPOSN, Last: NOPOSN}
Functions ¶
func Bytes2Hex ¶
Bytes2Hex duplicates the same-named function found in common, because we want to better control dependencies
func FormattedDate ¶
func Hex2Bytes ¶
Hex2Bytes duplicates the same-named function found in common, because we want to better control dependencies
func IsPrecompile ¶
IsPrecompile Returns true if the address is not a precompile and not the zero address
func IsValidAddress ¶
func IsValidAddressE ¶
func MustParseFloat64 ¶
func MustParseInt64 ¶
func MustParseUint64 ¶
Types ¶
type Address ¶
Address is a wrapper for go-ethereum's Address type that always return lower case hex.
func AddressFromPath ¶
AddressFromPath returns an address from a path -- is assumes the filename is a valid address starting with 0x and ends with the fileType. if the path does not contain an address, an error is returned. If the path does not end with the given fileType, it panics.
func BytesToAddress ¶
func GetTestPublisher ¶
func GetTestPublisher() Address
GetTestPublisher does not get customized per chain. We can only test against mainnet currently
func HexToAddress ¶
HexToAddress returns new address with the given string as value.
func (Address) CheckSum ¶
CheckSum returns the checksum address of the given address. We might want this, for example, to pick up ABIs and source code from Sourcify which requires checksum addresses.
func (Address) MarshalText ¶
MarshalText is used by Stringer don't remove
func (*Address) UnmarshalJSON ¶
type BlockRange ¶
type BlockRange FileRange // sugar
type Ether ¶
Ether encapsulates big.Float so we can Unmarshal strings into various of our types. This is necessary because we export big.Floats to Json strings so we don't lose precision. The types mostly just cast to the big.Float and call in to the identical functions.
func (*Ether) MarshalJSON ¶
func (*Ether) SetFloat64 ¶
func (*Ether) UnmarshalJSON ¶
type FileRange ¶
func RangeFromFilename ¶
RangeFromFilename returns a FileRange and ignore any errors
func RangeFromFilenameE ¶
RangeFromFilenameE returns a block range given a chunk filename. The format of filenames may be start-end.bin (start and end are nine digit and zero-padded to the left) or start.txt
func RangeFromRangeString ¶
RangeFromRangeString returns a file range from a string
func (*FileRange) EarlierThan ¶
EarlierThan returns true if range is strictly before the given needle range
func (*FileRange) EarlierThanB ¶
EarlierThanB returns true if the range is strictly before the given block
func (*FileRange) Follows ¶
Follows returns true if the range is strictly after the needle range. (If 'sequential' is true, then the first block in the range must be one more than the last block in the needle range.)
func (*FileRange) Intersects ¶
Intersects returns true if the two ranges intersect
func (*FileRange) IntersectsB ¶
IntersectsB returns true if the block is inside the range (inclusive on both ends)
func (*FileRange) LaterThan ¶
LaterThan returns true if range is strictly after the given needle range
func (*FileRange) LaterThanB ¶
LaterThanB returns true if the range is strictly after the given block
func (*FileRange) Preceeds ¶
Preceeds returns true if the range is strictly before the needle range. (If 'sequential' is true, then the last block in the range must be one less than the first block in the needle range.) If the needle range starts at zero, returns false (nothing is before the first range)
func (*FileRange) RangeToFilename ¶
RangeToFilename returns a fileName and existence bool given a file range and a type
type Hash ¶
Hash is a wrapper for go-ethereum's Hash type that always return lower case hex.
func BytesToHash ¶
func (*Hash) Hex ¶
Hex returns string representation of an hash. Unlike addresses, we do not shorten zero hashes.
func (Hash) MarshalText ¶
MarshalText is used by Stringer don't remove
func (*Hash) UnmarshalJSON ¶
type RecordRange ¶
type TimestampRange ¶
type Value ¶
type Value uint64 // allows for json parsing
type Value = uint64 // as an alias
func MustParseValue ¶
func (*Value) UnmarshalJSON ¶
type Wei ¶
Wei is a type in its own right. This means we can extend it by adding our own methods, such as UnMarshalJSON and MarshalJSON which are required because our Json encodes big.Ints as strings. Note that