Roy Crihfield
9f967abfb9
refactor packages, flags, subscriptions also DRY up builder tests use mockgen
63 lines
1.7 KiB
Go
63 lines
1.7 KiB
Go
package adapt
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
"github.com/ethereum/go-ethereum/params"
|
|
"github.com/ethereum/go-ethereum/trie"
|
|
|
|
plugeth "github.com/openrelayxyz/plugeth-utils/core"
|
|
plugeth_params "github.com/openrelayxyz/plugeth-utils/restricted/params"
|
|
)
|
|
|
|
func StateAccount(a *plugeth.StateAccount) *types.StateAccount {
|
|
return &types.StateAccount{
|
|
Nonce: a.Nonce,
|
|
Balance: a.Balance,
|
|
Root: common.Hash(a.Root),
|
|
CodeHash: a.CodeHash,
|
|
}
|
|
}
|
|
|
|
func ChainConfig(cc *plugeth_params.ChainConfig) *params.ChainConfig {
|
|
return ¶ms.ChainConfig{
|
|
ChainID: cc.ChainID,
|
|
HomesteadBlock: cc.HomesteadBlock,
|
|
DAOForkBlock: cc.DAOForkBlock,
|
|
DAOForkSupport: cc.DAOForkSupport,
|
|
EIP150Block: cc.EIP150Block,
|
|
EIP155Block: cc.EIP155Block,
|
|
EIP158Block: cc.EIP158Block,
|
|
ByzantiumBlock: cc.ByzantiumBlock,
|
|
ConstantinopleBlock: cc.ConstantinopleBlock,
|
|
PetersburgBlock: cc.PetersburgBlock,
|
|
IstanbulBlock: cc.IstanbulBlock,
|
|
MuirGlacierBlock: cc.MuirGlacierBlock,
|
|
BerlinBlock: cc.BerlinBlock,
|
|
LondonBlock: cc.LondonBlock,
|
|
}
|
|
}
|
|
|
|
func NodeIterator(it plugeth.NodeIterator) trie.NodeIterator {
|
|
return nodeiter{it}
|
|
}
|
|
|
|
type nodeiter struct {
|
|
plugeth.NodeIterator
|
|
}
|
|
|
|
func (it nodeiter) Hash() common.Hash {
|
|
return common.Hash(it.NodeIterator.Hash())
|
|
}
|
|
|
|
func (it nodeiter) Parent() common.Hash {
|
|
return common.Hash(it.NodeIterator.Parent())
|
|
}
|
|
|
|
func (it nodeiter) AddResolver(resolver trie.NodeResolver) {
|
|
r := func(owner plugeth.Hash, path []byte, hash plugeth.Hash) []byte {
|
|
return resolver(common.Hash(owner), path, common.Hash(hash))
|
|
}
|
|
it.NodeIterator.AddResolver(r)
|
|
}
|