Changes made to support unity across all plugeth projects with resepct to consensus engine.

This commit is contained in:
philip-morlier
2023-07-31 12:43:06 -07:00
parent 477985fdcd
commit bb43b2cbc4
6 changed files with 41 additions and 88 deletions
@@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
gparams "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
@@ -463,6 +464,28 @@ func (b *Backend) ChainConfig() *params.ChainConfig {
return b.chainConfig
}
func CloneChainConfig(cf *gparams.ChainConfig) *params.ChainConfig {
result := &params.ChainConfig{}
nval := reflect.ValueOf(result)
ntype := nval.Elem().Type()
lval := reflect.ValueOf(cf)
for i := 0; i < nval.Elem().NumField(); i++ {
field := ntype.Field(i)
v := nval.Elem().FieldByName(field.Name)
lv := lval.Elem().FieldByName(field.Name)
log.Info("Checking value for", "field", field.Name)
if lv.Kind() != reflect.Invalid {
// If core.ChainConfig doesn't have this field, skip it.
if v.Type() == lv.Type() && lv.CanSet() {
lv.Set(v)
} else {
convertAndSet(lv, v)
}
}
}
return result
}
func (b *Backend) GetTrie(h core.Hash) (core.Trie, error) {
tr, err := trie.NewStateTrie(trie.TrieID(common.Hash(h)), trie.NewDatabase(b.b.ChainDb()))
if err != nil {
+1 -1
View File
@@ -11,7 +11,7 @@ type dbWrapper struct {
db ethdb.Database
}
func NewDB(d ethdb.Database) restricted.Database {
func NewDb(d ethdb.Database) restricted.Database {
return &dbWrapper{d}
}