Documentation
¶
Index ¶
- Constants
- Variables
- func CopyBytes(b []byte) (copiedBytes []byte)
- func Decode(input string) ([]byte, error)
- func DeleteIndex[S ~[]E, E any](s S, i int) S
- func Detach(ctx context.Context) context.Context
- func EncodeToBytes(val interface{}) ([]byte, error)
- func Err(errors ...error) error
- func FromHex(s string) []byte
- func GetStacktrace(all bool) string
- func IsSortedAndUnique[T Sortable[T]](s []T) bool
- func IsSortedAndUniqueByHash[T ~[]byte](s []T) bool
- func IsSortedAndUniqueOrdered[T cmp.Ordered](s []T) bool
- func IsSortedBytes[T ~[]byte](s []T) bool
- func MustDecode(input string) []byte
- func MustParseBig256(s string) *big.Int
- func PaddedBigBytes(bigint *big.Int, n int) []byte
- func ParseBig256(s string) (*big.Int, bool)
- func RandomBytes(n int) []byte
- func Sort[T Sortable[T]](s []T)
- func SortByHash[T ~[]byte](s []T)
- func UnmarshalFixedJSON(typ reflect.Type, input, out []byte) error
- func Zero[T any]() (_ T)
- type Address
- type Atomic
- type Bytes
- type BytesPool
- type Hash
- type Sortable
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Variables ¶
var ( // Big0 is 0 represented as a big.Int Big0 = big.NewInt(0) // Big1 is 1 represented as a big.Int Big1 = big.NewInt(1) )
Functions ¶
func DeleteIndex ¶ added in v1.4.18
DeleteIndex moves the last element in the slice to index [i] and shrinks the size of the slice by 1.
This is an O(1) operation that allows the removal of an element from a slice when the order of the slice is not important.
If [i] is out of bounds, this function will panic.
func EncodeToBytes ¶
EncodeToBytes encodes the given values to RLP. This is a minimal implementation specifically for CreateAddress.
func FromHex ¶
FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x".
func GetStacktrace ¶ added in v1.4.18
func IsSortedAndUnique ¶ added in v1.4.18
Returns true iff the elements in [s] are unique and sorted.
func IsSortedAndUniqueByHash ¶ added in v1.4.18
Returns true iff the elements in [s] are unique and sorted based by their hashes.
func IsSortedAndUniqueOrdered ¶ added in v1.4.18
Returns true iff the elements in [s] are unique and sorted.
func IsSortedBytes ¶ added in v1.4.18
Returns true iff the elements in [s] are sorted.
func MustDecode ¶
MustDecode decodes a hex string with 0x prefix. It panics for invalid input.
func MustParseBig256 ¶
MustParseBig256 parses a hex or decimal string as a quantity of at most 256 bits. The result has 256 bits (32 bytes). Leading zeros are kept as required.
func PaddedBigBytes ¶
PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func ParseBig256 ¶
ParseBig256 parses a hex or decimal string as a quantity of at most 256 bits. The result has 256 bits (32 bytes). Leading zeros are kept as required.
func RandomBytes ¶ added in v1.4.18
RandomBytes returns a slice of n random bytes Intended for use in testing
func SortByHash ¶ added in v1.4.18
func SortByHash[T ~[]byte](s []T)
Sorts the elements of [s] based on their hashes.
func UnmarshalFixedJSON ¶
UnmarshalFixedJSON decodes the input as a string with 0x prefix and required length. The output given is assumed to be large enough.
Types ¶
type Address ¶
type Address [AddressLength]byte
Address represents the 20 byte address of an Ethereum account.
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.
type Atomic ¶ added in v1.4.18
type Atomic[T any] struct { // contains filtered or unexported fields }
func (*Atomic[T]) MarshalJSON ¶ added in v1.4.18
func (*Atomic[T]) UnmarshalJSON ¶ added in v1.4.18
type Bytes ¶
type Bytes []byte
Bytes marshals/unmarshals as a JSON string with 0x prefix. The empty slice marshals as "0x".
func (Bytes) MarshalText ¶
MarshalText implements encoding.TextMarshaler
type BytesPool ¶ added in v1.4.18
BytesPool tracks buckets of available buffers to be allocated. Each bucket allocates buffers of the following length:
0 1 3 7 15 31 63 127 ... MaxInt
In order to allocate a buffer of length 19 (for example), we calculate the number of bits required to represent 19 (5). And therefore allocate a slice from bucket 5, which has length 31. This is the bucket which produces the smallest slices that are at least length 19.
When replacing a buffer of length 19, we calculate the number of bits required to represent 20 (5). And therefore place the slice into bucket 4, which has length 15. This is the bucket which produces the largest slices that a length 19 slice can be used for.
func NewBytesPool ¶ added in v1.4.18
func NewBytesPool() *BytesPool
type Hash ¶
type Hash [HashLength]byte
Hash represents the 32 byte Keccak256 hash of arbitrary data.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
crypto
|
|
|
keychain/keychainmock
Package keychainmock is a generated GoMock package.
|
Package keychainmock is a generated GoMock package. |
|
Package filesystem is a generated GoMock package.
|
Package filesystem is a generated GoMock package. |
|
filesystemmock
Package filesystemmock is a generated GoMock package.
|
Package filesystemmock is a generated GoMock package. |
|
Package hashing is a generated GoMock package.
|
Package hashing is a generated GoMock package. |
|
hashingmock
Package hashingmock is a generated GoMock package.
|
Package hashingmock is a generated GoMock package. |
|
iteratormock
Package iteratormock is a generated GoMock package.
|
Package iteratormock is a generated GoMock package. |
|
resourcemock
Package resourcemock is a generated GoMock package.
|
Package resourcemock is a generated GoMock package. |