mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 17:44:29 +00:00
fdbba5202b
* squash commits * enable storage cache * make linter happy * fix subtree prefix len check * save cahnges to test master * remove restriction on prefix len * fix comparison of last bits * fix wrong alignment * remove debug prints * commit current state * commit current state * avoid changing state of resolver from multiwalk * remove debug code * remove debug code * remove debug code * remove unnecessary copy * make code more readable * reduce rebuildHashes initial resolution * fix test after rebase to master * make code more readable * improve pruner * pruner add IntermediateCache bucket * fix panic in Walk on short keys * reduce allocations for storage keys decompression by increasing default buffer size * re-run CI * fix iterator behaviour * rename cache to hash for unification * re-run ci * avoid using underlying DB * hash all subtree nodes before unload * fix getNode method * need to check node type, not parent - before put to hashBucket * return back parent type check, doesn't work without it. * don't recalculate hash again * move unloadFunc from trie to pruner * rename bucket to shorter name * rename bucket to shorter name * clean * rebase to master
26 lines
603 B
Go
26 lines
603 B
Go
package trie
|
|
|
|
// CompressNibbles - supports only even number of nibbles
|
|
//
|
|
// HI_NIBBLE(b) = (b >> 4) & 0x0F
|
|
// LO_NIBBLE(b) = b & 0x0F
|
|
func CompressNibbles(nibbles []byte, out *[]byte) {
|
|
tmp := (*out)[:0]
|
|
for i := 0; i < len(nibbles); i += 2 {
|
|
tmp = append(tmp, nibbles[i]<<4|nibbles[i+1])
|
|
}
|
|
*out = tmp
|
|
}
|
|
|
|
// DecompressNibbles - supports only even number of nibbles
|
|
//
|
|
// HI_NIBBLE(b) = (b >> 4) & 0x0F
|
|
// LO_NIBBLE(b) = b & 0x0F
|
|
func DecompressNibbles(in []byte, out *[]byte) {
|
|
tmp := (*out)[:0]
|
|
for i := 0; i < len(in); i++ {
|
|
tmp = append(tmp, (in[i]>>4)&0x0F, in[i]&0x0F)
|
|
}
|
|
*out = tmp
|
|
}
|