import { hash } from '@liskhq/lisk-cryptography' ; import { leafData } from './utils' ; export class Leaf { private readonly _key : Buffer ; private _value : Buffer ; private _hash : Buffer ; private _data : Buffer ; public constructor ( key , value ) { this . _key = key ; this . _value = value ; this . _data = leafData ( this . _key , this . _value ) ; this . _hash = hash ( this . _data ) ; } public get hash ( ) { return this . _hash ; } public get key ( ) { return this . _key ; } public get value ( ) { return this . _value ; } public get data ( ) { return this . _data ; } public update ( newValue ) { this . _value = newValue ; this . _data = leafData ( this . _key , this . _value ) ; this . _hash = hash ( this . _data ) ; } }