types

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(b []byte) uint64

func HashInt

func HashInt(i int) uint64

func HashInt16

func HashInt16(i int16) uint64

func HashInt32

func HashInt32(i int32) uint64

func HashInt64

func HashInt64(i int64) uint64

func HashInt8

func HashInt8(i int8) uint64

func HashString

func HashString(s string) uint64

func HashUint

func HashUint(i uint) uint64

func HashUint16

func HashUint16(u uint16) uint64

func HashUint32

func HashUint32(u uint32) uint64

func HashUint64

func HashUint64(u uint64) uint64

func HashUint8

func HashUint8(u uint8) uint64

Types

type Bytes added in v0.8.22

type Bytes []byte

type Commitment added in v0.8.22

type Commitment [32]byte

func CommitmentFromUint256 added in v0.8.22

func CommitmentFromUint256(n *U256) (Commitment, error)

func (Commitment) Equals added in v0.8.22

func (c Commitment) Equals(other Commitment) bool

func (Commitment) String added in v0.8.22

func (c Commitment) String() string

func (Commitment) Uint256 added in v0.8.22

func (c Commitment) Uint256() *U256

type FIFOMap

type FIFOMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewFIFOMap

func NewFIFOMap[K comparable, V any](size, shards int, hashFn HashFn[K]) *FIFOMap[K, V]

NewFIFOMap returns a FIFO map that internally uses the sharded map. It keeps count of all the items inserted, and when we exceed the size, values will be evicted using the FIFO (first in, first out) policy.

func (*FIFOMap[K, V]) Del

func (m *FIFOMap[K, V]) Del(key K)

func (*FIFOMap[K, V]) Get

func (m *FIFOMap[K, V]) Get(key K) (V, bool)

func (*FIFOMap[K, V]) Has

func (m *FIFOMap[K, V]) Has(key K) bool

func (*FIFOMap[K, V]) Len

func (m *FIFOMap[K, V]) Len() int

func (*FIFOMap[K, V]) Put

func (m *FIFOMap[K, V]) Put(key K, val V)

type HashFn

type HashFn[K comparable] func(k K) uint64
type Header struct {
	Height           uint64  `json:"height"`
	Timestamp        uint64  `json:"timestamp"`
	L1Head           uint64  `json:"l1_head"`
	TransactionsRoot NmtRoot `json:"transactions_root"`
}

func (*Header) Commit added in v0.8.22

func (self *Header) Commit() Commitment

func (*Header) UnmarshalJSON added in v0.8.22

func (h *Header) UnmarshalJSON(b []byte) error

type NmtRoot added in v0.8.22

type NmtRoot struct {
	Root Bytes `json:"root"`
}

func (*NmtRoot) Commit added in v0.8.22

func (self *NmtRoot) Commit() Commitment

func (*NmtRoot) UnmarshalJSON added in v0.8.22

func (r *NmtRoot) UnmarshalJSON(b []byte) error

type RawCommitmentBuilder added in v0.8.22

type RawCommitmentBuilder struct {
	// contains filtered or unexported fields
}

func NewRawCommitmentBuilder added in v0.8.22

func NewRawCommitmentBuilder(name string) *RawCommitmentBuilder

func (*RawCommitmentBuilder) ConstantString added in v0.8.22

func (b *RawCommitmentBuilder) ConstantString(s string) *RawCommitmentBuilder

Append a constant string to the running hash.

WARNING: The string `s` must be a constant. This function does not encode the length of `s` in the hash, which can lead to domain collisions when different strings with different lengths are used depending on the input object.

func (*RawCommitmentBuilder) Field added in v0.8.22

Include a named field of another committable type.

func (*RawCommitmentBuilder) Finalize added in v0.8.22

func (b *RawCommitmentBuilder) Finalize() Commitment

func (*RawCommitmentBuilder) FixedSizeBytes added in v0.8.22

func (b *RawCommitmentBuilder) FixedSizeBytes(bytes Bytes) *RawCommitmentBuilder

Append a fixed size byte array to the running hash.

WARNING: Go's type system cannot express the requirement that `bytes` is a fixed size array of any size. The best we can do is take a dynamically sized slice. However, this function uses a fixed-size encoding; namely, it does not encode the length of `bytes` in the hash, which can lead to domain collisions when this function is called with a slice which can have different lengths depending on the input object.

The caller must ensure that this function is only used with slices whose length is statically determined by the type being committed to.

func (*RawCommitmentBuilder) FixedSizeField added in v0.8.22

func (b *RawCommitmentBuilder) FixedSizeField(f string, bytes Bytes) *RawCommitmentBuilder

Include a named field of fixed length in the hash.

WARNING: Go's type system cannot express the requirement that `bytes` is a fixed size array of any size. The best we can do is take a dynamically sized slice. However, this function uses a fixed-size encoding; namely, it does not encode the length of `bytes` in the hash, which can lead to domain collisions when this function is called with a slice which can have different lengths depending on the input object.

The caller must ensure that this function is only used with slices whose length is statically determined by the type being committed to.

func (*RawCommitmentBuilder) OptionalField added in v0.8.22

func (*RawCommitmentBuilder) Uint256 added in v0.8.22

Include a value of type `uint256` in the hash.

func (*RawCommitmentBuilder) Uint256Field added in v0.8.22

func (b *RawCommitmentBuilder) Uint256Field(f string, n *U256) *RawCommitmentBuilder

Include a named field of type `uint256` in the hash.

func (*RawCommitmentBuilder) Uint64 added in v0.8.22

Include a value of type `uint64` in the hash.

func (*RawCommitmentBuilder) Uint64Field added in v0.8.22

Include a named field of type `uint64` in the hash.

func (*RawCommitmentBuilder) VarSizeBytes added in v0.8.22

func (b *RawCommitmentBuilder) VarSizeBytes(bytes Bytes) *RawCommitmentBuilder

Include a byte array whose length can be dynamic to the running hash.

func (*RawCommitmentBuilder) VarSizeField added in v0.8.22

func (b *RawCommitmentBuilder) VarSizeField(f string, bytes Bytes) *RawCommitmentBuilder

Include a named field of dynamic length in the hash.

type SEQTransaction

type SEQTransaction struct {
	Namespace   string `json:"namespace"`
	Tx_id       string `json:"tx_id"`
	Index       uint64 `json:"tx_index"`
	Transaction []byte `json:"transaction"`
}

type SequencerBlock

type SequencerBlock struct {
	StateRoot ids.ID                       `json:"state_root"`
	Prnt      ids.ID                       `json:"parent"`
	Tmstmp    int64                        `json:"timestamp"`
	Hght      uint64                       `json:"height"`
	Txs       map[string][]*SEQTransaction `json:"transactions"`
}

type ShardedMap

type ShardedMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewShardedMap

func NewShardedMap[K comparable, V any](size, numShards int, hashFn HashFn[K]) *ShardedMap[K, V]

NewShardedMap returns a new sharded map with `numShards` shards. Each of the shards are pre-allocated with a length of `size` / `numShards`. `size` is not the max size by any means, but just an estimation. hashFn is used to hash the key.

func (*ShardedMap[K, V]) Del

func (m *ShardedMap[K, V]) Del(key K)

Del deletes the value from the map.

func (*ShardedMap[K, V]) Get

func (m *ShardedMap[K, V]) Get(key K) (v V, ok bool)

Get returns the value and true if the value is present, otherwise it returns the default value and false.

func (*ShardedMap[K, V]) Has

func (m *ShardedMap[K, V]) Has(key K) bool

Has returns true if the key is present.

func (*ShardedMap[K, V]) Len

func (m *ShardedMap[K, V]) Len() int

Len returns the count of all the items in the sharded map. It will RLock every one of the shards so use it scarcely.

func (*ShardedMap[K, V]) Put

func (m *ShardedMap[K, V]) Put(key K, val V)

Put puts the key value pair in the map.

type U256

type U256 struct {
	big.Int
}

A BigInt type which serializes to JSON a a hex string.

func NewU256

func NewU256() *U256

func (U256) MarshalJSON

func (i U256) MarshalJSON() ([]byte, error)

func (*U256) SetBigInt

func (i *U256) SetBigInt(n *big.Int) *U256

func (*U256) SetBytes

func (i *U256) SetBytes(buf [32]byte) *U256

func (*U256) SetUint64

func (i *U256) SetUint64(n uint64) *U256

func (*U256) UnmarshalJSON

func (i *U256) UnmarshalJSON(in []byte) error

Jump to

Keyboard shortcuts

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