Documentation ¶
Index ¶
- func HashBytes(b []byte) uint64
- func HashInt(i int) uint64
- func HashInt16(i int16) uint64
- func HashInt32(i int32) uint64
- func HashInt64(i int64) uint64
- func HashInt8(i int8) uint64
- func HashString(s string) uint64
- func HashUint(i uint) uint64
- func HashUint16(u uint16) uint64
- func HashUint32(u uint32) uint64
- func HashUint64(u uint64) uint64
- func HashUint8(u uint8) uint64
- type Bytes
- type Commitment
- type FIFOMap
- type HashFn
- type Header
- type NmtRoot
- type RawCommitmentBuilder
- func (b *RawCommitmentBuilder) ConstantString(s string) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Field(f string, c Commitment) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Finalize() Commitment
- func (b *RawCommitmentBuilder) FixedSizeBytes(bytes Bytes) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) FixedSizeField(f string, bytes Bytes) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) OptionalField(f string, c *Commitment) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Uint256(n *U256) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Uint256Field(f string, n *U256) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Uint64(n uint64) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) Uint64Field(f string, n uint64) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) VarSizeBytes(bytes Bytes) *RawCommitmentBuilder
- func (b *RawCommitmentBuilder) VarSizeField(f string, bytes Bytes) *RawCommitmentBuilder
- type SEQTransaction
- type SequencerBlock
- type ShardedMap
- type U256
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HashString ¶
func HashUint16 ¶
func HashUint32 ¶
func HashUint64 ¶
Types ¶
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.
type HashFn ¶
type HashFn[K comparable] func(k K) uint64
type Header ¶ added in v0.8.22
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
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
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
func (b *RawCommitmentBuilder) Field(f string, c Commitment) *RawCommitmentBuilder
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 (b *RawCommitmentBuilder) OptionalField(f string, c *Commitment) *RawCommitmentBuilder
func (*RawCommitmentBuilder) Uint256 ¶ added in v0.8.22
func (b *RawCommitmentBuilder) Uint256(n *U256) *RawCommitmentBuilder
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
func (b *RawCommitmentBuilder) Uint64(n uint64) *RawCommitmentBuilder
Include a value of type `uint64` in the hash.
func (*RawCommitmentBuilder) Uint64Field ¶ added in v0.8.22
func (b *RawCommitmentBuilder) Uint64Field(f string, n uint64) *RawCommitmentBuilder
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 SequencerBlock ¶
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 ¶
A BigInt type which serializes to JSON a a hex string.