class Fremkit::Trees::Trie

Overview

Implements a hexary Merkle Patricia Tree (MPT), which is not backed by a data store: all values are stored in memory.

trie = Trie.new
trie.root_hash # => [86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33]

Defined in:

common/trie.cr

Constant Summary

EmptyRoot = Bytes[86, 232, 31, 23, 27, 204, 85, 166, 255, 131, 69, 230, 146, 192, 248, 110, 91, 72, 224, 27, 153, 108, 173, 192, 1, 98, 47, 181, 227, 99, 180, 33]

Constructors

Instance Method Summary

Instance methods inherited from class Fremkit::Trees::MerkleTree(Slice(UInt8), Slice(UInt8), Slice(UInt8))

get!(key : K(UInt8)) : V(UInt8) get!, get?(key : K(UInt8)) : V(UInt8) | Nil get?, insert(key : K(UInt8), value : V(UInt8)) insert, root_hash : H(UInt8) root_hash

Instance methods inherited from class Object

from_rlp(rlp : Bytes) : Tuple(self, UInt32) from_rlp, to_rlp : Bytes to_rlp

Class methods inherited from class Object

from_rlp(rlp : Bytes) : Tuple(self, UInt32) from_rlp

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def common_length(key : Bytes, prefix : Bytes) : UInt32 #

[View source]
def get!(key : Bytes) : Bytes #

[View source]
def get?(key : Bytes) : Bytes | Nil #

[View source]
def insert(key : Bytes, value : Bytes) #

[View source]
def root_hash : Bytes #

[View source]