MerkleTree

merkle.MerkleTree
See theMerkleTree companion class
object MerkleTree

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
MerkleTree.type

Members list

Type members

Classlikes

class Leaf extends MerkleTree

Attributes

Supertypes
class MerkleTree
class Object
trait Matchable
class Any
class Node extends MerkleTree

Attributes

Supertypes
class MerkleTree
class Object
trait Matchable
class Any

Value members

Concrete methods

def deserialise(lines: Vector[String], fromBytesId: String => Option[ToBytes[Any]] = ..., fromHasherId: String => Option[Hasher] = ...): Result[MerkleTree]

Deserialises the Merkle tree from a list of strings. IMPORTANT: the hashes are read from the serialised format and cached in the tree – meaning the tree will never recompute the hashes even if they depend on external factors such as file system.

Deserialises the Merkle tree from a list of strings. IMPORTANT: the hashes are read from the serialised format and cached in the tree – meaning the tree will never recompute the hashes even if they depend on external factors such as file system.

This means an instance of the tree returned from this method is frozen in time and is safe to compare to another tree of same structure constructed over live data

Value parameters

fromBytesId

function that produces an instance of ToBytes from its serialised ID (see ToBytes.fromStringID)

fromHasherId

function that produces an instance of Hasher from its serialised ID (see Hasher.fromStringID)

lines

lines of the serialised tree (without line end markers)

Attributes

def render(tree: MerkleTree, colors: Boolean = ...): Vector[String]

Renders a given MerkleTree as a vector of strings.

Renders a given MerkleTree as a vector of strings.

This representation is purely for visualisation – for reversible serialisation use serialise

Attributes

def serialise(tree: MerkleTree, toHashID: Hasher => Option[String] = ..., toBytesID: (ToBytes[Any]) => Option[String] = ...): Result[Vector[String]]

Serialises the tree to a list of lines that can be saved to a file and read back again using the deserialise method.

Serialises the tree to a list of lines that can be saved to a file and read back again using the deserialise method.

IMPORTANT: serialisation will force the evaluation of all the hashes

Value parameters

toBytesID

function to convert a ToBytes instance to a string ID (see ToBytes.toStringID)

toHashID

function to convert a Hasher to a string ID (see Hasher.toStringID)

tree

tree to serialise

Attributes