types

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: BSD-3-Clause Imports: 5 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 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 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