package coreth
import (
"crypto/ecdsa"
"fmt"
"io"
"os"
"github.com/ava-labs/coreth/consensus/dummy"
"github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth"
"github.com/ava-labs/coreth/miner"
"github.com/ava-labs/coreth/node"
"github.com/ava-labs/go-ethereum/common"
"github.com/ava-labs/go-ethereum/core/state"
"github.com/ava-labs/go-ethereum/core/types"
"github.com/ava-labs/go-ethereum/crypto"
"github.com/ava-labs/go-ethereum/ethdb"
"github.com/ava-labs/go-ethereum/event"
"github.com/ava-labs/go-ethereum/log"
"github.com/ava-labs/go-ethereum/rpc"
"github.com/mattn/go-isatty"
)
type Tx = types.Transaction
type Block = types.Block
type Hash = common.Hash
type ETHChain struct {
backend *eth.Ethereum
cb *dummy.ConsensusCallbacks
mcb *miner.MinerCallbacks
bcb *eth.BackendCallbacks
}
func isLocalBlock(block *types.Block) bool {
return false
}
// NewETHChain creates an Ethereum blockchain with the given configs.
func NewETHChain(config *eth.Config, nodecfg *node.Config, etherBase *common.Address, chainDB ethdb.Database) *ETHChain {
if config == nil {
config = ð.DefaultConfig
}
if nodecfg == nil {
nodecfg = &node.Config{}
}
mux := new(event.TypeMux)
ctx, ep, err := node.NewServiceContext(nodecfg, mux)
if err != nil {
panic(err)
}
if ep != "" {
log.Info(fmt.Sprintf("temporary keystore = %s", ep))
}
cb := new(dummy.ConsensusCallbacks)
mcb := new(miner.MinerCallbacks)
bcb := new(eth.BackendCallbacks)
backend, _ := eth.New(&ctx, config, cb, mcb, bcb, chainDB)
chain := ÐChain{backend: backend, cb: cb, mcb: mcb, bcb: bcb}
if etherBase == nil {
etherBase = &common.Address{
1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
}
backend.SetEtherbase(*etherBase)
return chain
}
func (self *ETHChain) Start() {
self.backend.StartMining(0)
}
func (self *ETHChain) Stop() {
self.backend.StopPart()
}
func (self *ETHChain) GenBlock() {
self.