types

package
v1.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2023 License: LGPL-3.0 Imports: 13 Imported by: 13 modules, 52 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	HashLength      = 32
	AddressLength   = 20
	BloomByteLength = 256
)

Lengths of hashes and addresses in bytes.

Variables

View Source
var (
	ErrSyntax        = fmt.Errorf("invalid hex string")
	ErrMissingPrefix = fmt.Errorf("hex string without 0x prefix")
	ErrOddLength     = fmt.Errorf("hex string of odd length")
)

hasherPool holds LegacyKeccak256 hashers for rlpHash.

Functions

func HexDecodeString added in v1.0.1

func HexDecodeString(s string) ([]byte, error)

HexDecodeString return rawBytes of a hex hash represent

func IsValidAddressByte added in v1.0.1

func IsValidAddressByte(data []byte) bool

Types

type Address

type Address struct {
	RawAddress [AddressLength]byte `json:"raw_address"`
	Address    string              `json:"address"`
}

func NewAddress added in v1.0.1

func NewAddress(b []byte) *Address

BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped address the left.

func NewAddressByStr added in v1.0.1

func NewAddressByStr(s string) *Address

func (*Address) Bytes

func (a *Address) Bytes() []byte

func (*Address) MarshalJSON

func (a *Address) MarshalJSON() ([]byte, error)

Serialize given address to JSON

func (*Address) MarshalJSONPB added in v1.2.0

func (a *Address) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error)

func (*Address) MarshalTo

func (a *Address) MarshalTo(data []byte) (int, error)

func (*Address) ProtoMessage added in v1.0.1

func (a *Address) ProtoMessage()

func (*Address) Reset added in v1.0.1

func (a *Address) Reset()

func (*Address) Set

func (a *Address) Set(other *Address)

Sets a to other

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.

func (*Address) SetString added in v1.0.1

func (a *Address) SetString(s string)

func (*Address) Size

func (a *Address) Size() int

func (*Address) String

func (a *Address) String() string

String returns an EIP55-compliant hex string representation of the address.

func (*Address) Unmarshal

func (a *Address) Unmarshal(data []byte) error

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(data []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Address) UnmarshalJSONPB added in v1.2.0

func (a *Address) UnmarshalJSONPB(m *jsonpb.Unmarshaler, data []byte) error

type Bloom added in v1.2.0

type Bloom [BloomByteLength]byte

func (*Bloom) Add added in v1.2.0

func (b *Bloom) Add(d []byte)

Add adds d to the filter. Future calls of Test(d) will return true.

func (Bloom) MarshalText added in v1.2.0

func (b Bloom) MarshalText() ([]byte, error)

MarshalText encodes b as a hex string with 0x prefix.

func (*Bloom) MarshalTo added in v1.2.0

func (b *Bloom) MarshalTo(data []byte) (int, error)

func (*Bloom) OrBloom added in v1.20.0

func (b *Bloom) OrBloom(bl *Bloom)

OrBloom executes an Or operation on the bloom

func (*Bloom) ProtoMessage added in v1.2.0

func (b *Bloom) ProtoMessage()

func (*Bloom) SetBytes added in v1.20.0

func (b *Bloom) SetBytes(d []byte)

SetBytes sets the content of b to the given bytes. It panics if d is not of suitable size.

func (*Bloom) Size added in v1.2.0

func (b *Bloom) Size() int

func (Bloom) Test added in v1.2.0

func (b Bloom) Test(topic []byte) bool

Test checks if the given topic is present in the bloom filter

func (*Bloom) Unmarshal added in v1.2.0

func (b *Bloom) Unmarshal(data []byte) error

func (*Bloom) UnmarshalText added in v1.2.0

func (b *Bloom) UnmarshalText(input []byte) error

UnmarshalText b as a hex string with 0x prefix.

type Hash

type Hash struct {
	RawHash [HashLength]byte `json:"raw_hash"`
	Hash    string           `json:"hash"`
}

func NewHash added in v1.0.1

func NewHash(b []byte) *Hash

func NewHashByStr added in v1.0.1

func NewHashByStr(s string) *Hash

func (*Hash) Bytes

func (h *Hash) Bytes() []byte

func (*Hash) CalculateHash added in v1.0.1

func (h *Hash) CalculateHash() ([]byte, error)

CalculateHash hashes the values of a TestContent

func (*Hash) Equals added in v1.0.1

func (h *Hash) Equals(other mt.Content) (bool, error)

Equals tests for equality of two Contents

func (*Hash) MarshalJSON

func (h *Hash) MarshalJSON() ([]byte, error)

Serialize given address to JSON

func (*Hash) MarshalJSONPB added in v1.2.0

func (h *Hash) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error)

func (*Hash) MarshalTo

func (h *Hash) MarshalTo(data []byte) (int, error)

func (*Hash) ProtoMessage added in v1.0.1

func (h *Hash) ProtoMessage()

func (*Hash) Reset added in v1.0.1

func (h *Hash) Reset()

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

func (*Hash) SetString added in v1.0.1

func (h *Hash) SetString(s string)

func (Hash) Size

func (h Hash) Size() int

func (*Hash) String

func (h *Hash) String() string

func (*Hash) Unmarshal

func (h *Hash) Unmarshal(data []byte) error

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

func (*Hash) UnmarshalJSONPB added in v1.2.0

func (h *Hash) UnmarshalJSONPB(m *jsonpb.Unmarshaler, data []byte) error

type KeccakState added in v1.20.0

type KeccakState interface {
	hash.Hash
	Read([]byte) (int, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL