Documentation ¶
Overview ¶
Copyright 2021 Erigon contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func BitLenToByteLen(bitLen int) (byteLen int)
- func ByteCount(b uint64) string
- func CliString2Array(input string) []string
- func Copy(b []byte) []byte
- func EnsureEnoughSize(in []byte, size int) []byte
- func FromHex(in string) []byte
- func IsHexAddress(s string) bool
- func MBToGB(b uint64) (float64, int)
- func PrioritizedSend[t any](ch chan t, msg t)
- func RootContext() (context.Context, context.CancelFunc)
- func SafeClose(ch chan struct{})
- func Stopped(ch <-chan struct{}) error
- type Address
- func (a Address) Bytes() []byte
- func (a Address) Format(s fmt.State, c rune)
- func (a Address) Hash() Hash
- func (a Address) Hex() string
- func (a Address) MarshalText() ([]byte, error)
- func (a *Address) Scan(src interface{}) error
- func (a *Address) SetBytes(b []byte)
- func (a Address) String() string
- func (a *Address) UnmarshalJSON(input []byte) error
- func (a *Address) UnmarshalText(input []byte) error
- func (a Address) Value() (driver.Value, error)
- type Bytes4
- func (b Bytes4) Format(s fmt.State, c rune)
- func (b Bytes4) Generate(rand *rand.Rand, size int) reflect.Value
- func (b Bytes4) Hex() string
- func (b Bytes4) MarshalText() ([]byte, error)
- func (b *Bytes4) SetBytes(i []byte)
- func (b Bytes4) String() string
- func (b Bytes4) TerminalString() string
- func (b *Bytes4) UnmarshalJSON(input []byte) error
- func (b *Bytes4) UnmarshalText(input []byte) error
- func (b Bytes4) Value() (driver.Value, error)
- type Bytes48
- func (b Bytes48) Format(s fmt.State, c rune)
- func (b Bytes48) Generate(rand *rand.Rand, size int) reflect.Value
- func (b Bytes48) Hex() string
- func (b Bytes48) MarshalText() ([]byte, error)
- func (b *Bytes48) SetBytes(i []byte)
- func (b Bytes48) String() string
- func (b Bytes48) TerminalString() string
- func (b *Bytes48) UnmarshalJSON(input []byte) error
- func (b *Bytes48) UnmarshalText(input []byte) error
- func (b Bytes48) Value() (driver.Value, error)
- type Bytes64
- func (b Bytes64) Format(s fmt.State, c rune)
- func (b Bytes64) Hex() string
- func (b Bytes64) MarshalText() ([]byte, error)
- func (b *Bytes64) SetBytes(i []byte)
- func (b Bytes64) String() string
- func (b Bytes64) TerminalString() string
- func (b *Bytes64) UnmarshalJSON(input []byte) error
- func (b *Bytes64) UnmarshalText(input []byte) error
- func (b Bytes64) Value() (driver.Value, error)
- type Bytes96
- func (b Bytes96) Format(s fmt.State, c rune)
- func (b Bytes96) Generate(rand *rand.Rand, size int) reflect.Value
- func (b Bytes96) Hex() string
- func (b Bytes96) MarshalText() ([]byte, error)
- func (b *Bytes96) SetBytes(i []byte)
- func (b Bytes96) String() string
- func (b Bytes96) TerminalString() string
- func (b *Bytes96) UnmarshalJSON(input []byte) error
- func (b *Bytes96) UnmarshalText(input []byte) error
- func (b Bytes96) Value() (driver.Value, error)
- type CodeRecord
- type Hash
- func (h Hash) Big() *big.Int
- func (h Hash) Bytes() []byte
- func (h Hash) Format(s fmt.State, c rune)
- func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value
- func (h Hash) Hex() string
- func (h Hash) MarshalText() ([]byte, error)
- func (h *Hash) Scan(src interface{}) error
- func (h *Hash) SetBytes(b []byte)
- func (h Hash) String() string
- func (h Hash) TerminalString() string
- func (h *Hash) UnmarshalJSON(input []byte) error
- func (h *Hash) UnmarshalText(input []byte) error
- func (h Hash) Value() (driver.Value, error)
Constants ¶
const ( Wei = 1 GWei = 1e9 Ether = 1e18 )
Variables ¶
var ( Big0 = big.NewInt(0) Big1 = big.NewInt(1) Big2 = big.NewInt(2) Big3 = big.NewInt(3) Big32 = big.NewInt(32) Big256 = big.NewInt(256) Big257 = big.NewInt(257) )
var ErrStopped = errors.New("stopped")
var ErrUnwind = errors.New("unwound")
Functions ¶
func BitLenToByteLen ¶
func CliString2Array ¶
func EnsureEnoughSize ¶
func IsHexAddress ¶
IsHexAddress verifies whether a string can represent a valid hex-encoded Ethereum address or not.
func PrioritizedSend ¶
func PrioritizedSend[t any](ch chan t, msg t)
PrioritizedSend message to channel, but if channel is full (slow consumer) - drop half of old messages (not new)
func RootContext ¶
func RootContext() (context.Context, context.CancelFunc)
Types ¶
type Address ¶
Address represents the 20 byte address of an Ethereum account.
func BigToAddress ¶
BigToAddress returns Address with byte values of b. If b is larger than len(h), b will be cropped from the left.
func BytesToAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped from the left.
func HexToAddress ¶
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func (Address) Format ¶
Format implements fmt.Formatter. Address supports the %v, %s, %v, %x, %X and %d format verbs.
func (Address) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a), b will be cropped from the left.
func (*Address) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Address) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Bytes4 ¶
func (Bytes4) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %v, %x, %X and %d format verbs.
func (Bytes4) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Bytes4) SetBytes ¶
SetBytes sets the hash to the value of i. If b is larger than len(h), b will be cropped from the left.
func (Bytes4) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Bytes4) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Bytes4) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Bytes4) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Bytes48 ¶
func (Bytes48) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %v, %x, %X and %d format verbs.
func (Bytes48) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Bytes48) SetBytes ¶
SetBytes sets the hash to the value of i. If b is larger than len(h), b will be cropped from the left.
func (Bytes48) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Bytes48) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Bytes48) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Bytes48) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Bytes64 ¶
func (Bytes64) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %v, %x, %X and %d format verbs.
func (Bytes64) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Bytes64) SetBytes ¶
SetBytes sets the hash to the value of i. If b is larger than len(h), b will be cropped from the left.
func (Bytes64) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Bytes64) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Bytes64) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Bytes64) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type Bytes96 ¶
func (Bytes96) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %v, %x, %X and %d format verbs.
func (Bytes96) MarshalText ¶
MarshalText returns the hex representation of a.
func (*Bytes96) SetBytes ¶
SetBytes sets the hash to the value of i. If b is larger than len(h), b will be cropped from the left.
func (Bytes96) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Bytes96) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Bytes96) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Bytes96) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.
type CodeRecord ¶
type Hash ¶
Hash represents the 32 byte Keccak256 hash of arbitrary data.
func BigToHash ¶
BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func CastToHash ¶
CastToHash - sets b to hash If b is larger than len(h), b will be cropped from the left. panics if input is shorter than 32 bytes, see https://go.dev/doc/go1.17#language faster than BytesToHash
func HexToHash ¶
HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) Format ¶
Format implements fmt.Formatter. Hash supports the %v, %s, %v, %x, %X and %d format verbs.
func (Hash) MarshalText ¶
MarshalText returns the hex representation of h.
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
func (Hash) String ¶
String implements the stringer interface and is used also by the logger when doing full logging into a file.
func (Hash) TerminalString ¶
TerminalString implements log.TerminalStringer, formatting a string for console output during logging.
func (*Hash) UnmarshalJSON ¶
UnmarshalJSON parses a hash in hex syntax.
func (*Hash) UnmarshalText ¶
UnmarshalText parses a hash in hex syntax.