mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
Implement the binary tree as specified in [eip-7864](https://eips.ethereum.org/EIPS/eip-7864). This will gradually replace verkle trees in the codebase. This is only running the tests and will not be executed in production, but will help me rebase some of my work, so that it doesn't bitrot as much. --------- Signed-off-by: Guillaume Ballet Co-authored-by: Parithosh Jayanthi <parithosh.jayanthi@ethereum.org> Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
// Copyright 2025 go-ethereum Authors
|
|
// This file is part of the go-ethereum library.
|
|
//
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package bintrie
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
)
|
|
|
|
type Empty struct{}
|
|
|
|
func (e Empty) Get(_ []byte, _ NodeResolverFn) ([]byte, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (e Empty) Insert(key []byte, value []byte, _ NodeResolverFn, depth int) (BinaryNode, error) {
|
|
var values [256][]byte
|
|
values[key[31]] = value
|
|
return &StemNode{
|
|
Stem: slices.Clone(key[:31]),
|
|
Values: values[:],
|
|
depth: depth,
|
|
}, nil
|
|
}
|
|
|
|
func (e Empty) Copy() BinaryNode {
|
|
return Empty{}
|
|
}
|
|
|
|
func (e Empty) Hash() common.Hash {
|
|
return common.Hash{}
|
|
}
|
|
|
|
func (e Empty) GetValuesAtStem(_ []byte, _ NodeResolverFn) ([][]byte, error) {
|
|
var values [256][]byte
|
|
return values[:], nil
|
|
}
|
|
|
|
func (e Empty) InsertValuesAtStem(key []byte, values [][]byte, _ NodeResolverFn, depth int) (BinaryNode, error) {
|
|
return &StemNode{
|
|
Stem: slices.Clone(key[:31]),
|
|
Values: values,
|
|
depth: depth,
|
|
}, nil
|
|
}
|
|
|
|
func (e Empty) CollectNodes(_ []byte, _ NodeFlushFn) error {
|
|
return nil
|
|
}
|
|
|
|
func (e Empty) toDot(parent string, path string) string {
|
|
return ""
|
|
}
|
|
|
|
func (e Empty) GetHeight() int {
|
|
return 0
|
|
}
|