new type + additional methods

This commit is contained in:
obscuren
2015-03-16 11:59:52 +01:00
parent b523441361
commit f486c0ae56
7 changed files with 107 additions and 62 deletions

View File

@ -6,8 +6,8 @@ import (
"fmt"
"sync"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func ParanoiaCheck(t1 *Trie, backend Backend) (bool, *Trie) {
@ -24,13 +24,13 @@ func ParanoiaCheck(t1 *Trie, backend Backend) (bool, *Trie) {
type Trie struct {
mu sync.Mutex
root Node
roothash []byte
roothash common.Hash
cache *Cache
revisions *list.List
}
func New(root []byte, backend Backend) *Trie {
func New(root common.Hash, backend Backend) *Trie {
trie := &Trie{}
trie.revisions = list.New()
trie.roothash = root
@ -51,6 +51,9 @@ func (self *Trie) Iterator() *Iterator {
}
func (self *Trie) Copy() *Trie {
// cheap copying method
var cpy common.Hash
cpy.Set(self.roothash[:])
cpy := make([]byte, 32)
copy(cpy, self.roothash)
trie := New(nil, nil)