types

package
v0.0.0-...-6a7e83e Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2022 License: LGPL-3.0 Imports: 13 Imported by: 7

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

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

HexDecodeString return rawBytes of a hex hash represent

func IsValidAddressByte

func IsValidAddressByte(data []byte) bool

Types

type Address

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

func NewAddress

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

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

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

func (*Address) MarshalTo

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

func (*Address) ProtoMessage

func (a *Address) ProtoMessage()

func (*Address) Reset

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

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

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

type Bloom

type Bloom [BloomByteLength]byte

func (*Bloom) Add

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

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

func (Bloom) MarshalText

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

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

func (*Bloom) MarshalTo

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

func (*Bloom) OrBloom

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

OrBloom executes an Or operation on the bloom

func (*Bloom) ProtoMessage

func (b *Bloom) ProtoMessage()

func (*Bloom) SetBytes

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

func (b *Bloom) Size() int

func (Bloom) Test

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

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

func (*Bloom) Unmarshal

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

func (*Bloom) UnmarshalText

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

func NewHash(b []byte) *Hash

func NewHashByStr

func NewHashByStr(s string) *Hash

func (*Hash) Bytes

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

func (*Hash) CalculateHash

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

CalculateHash hashes the values of a TestContent

func (*Hash) Equals

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

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

func (*Hash) MarshalTo

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

func (*Hash) ProtoMessage

func (h *Hash) ProtoMessage()

func (*Hash) Reset

func (h *Hash) Reset()

func (*Hash) SetBytes

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

func (*Hash) SetString

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

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

type KeccakState

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