Add empty total difficulty to test blocks and clean up stopping the node

This commit is contained in:
Gustav Simonsson 2015-03-06 03:25:57 +01:00
parent 676a0de58d
commit 27c42ea934
3 changed files with 31 additions and 3 deletions

View File

@ -168,7 +168,7 @@ func main() {
logger.Flush() logger.Flush()
}() }()
utils.HandleInterrupt() //utils.HandleInterrupt()
utils.InitConfig(VmType, ConfigFile, Datadir, "ethblocktest") utils.InitConfig(VmType, ConfigFile, Datadir, "ethblocktest")
@ -190,12 +190,17 @@ func main() {
MinerThreads: MinerThreads, MinerThreads: MinerThreads,
}) })
utils.StartEthereumForTest(ethereum)
utils.StartRpc(ethereum, RpcListenAddress, RpcPort) utils.StartRpc(ethereum, RpcListenAddress, RpcPort)
utils.StartEthereum(ethereum)
ethereum.ChainManager().ResetWithGenesisBlock(blocks[0]) ethereum.ChainManager().ResetWithGenesisBlock(blocks[0])
// bph := ethereum.ChainManager().GetBlock(blocks[1].Header().ParentHash)
// fmt.Println("bph: ", bph)
// fmt.Println("HURR: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData()))) //fmt.Println("b0: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
//fmt.Println("b0: ", hex.EncodeToString(blocks[0].Hash()))
//fmt.Println("b1: ", hex.EncodeToString(ethutil.Encode(blocks[1].RlpData())))
//fmt.Println("b1: ", hex.EncodeToString(blocks[1].Hash()))
go ethereum.ChainManager().InsertChain(types.Blocks{blocks[1]}) go ethereum.ChainManager().InsertChain(types.Blocks{blocks[1]})
fmt.Println("OK! ") fmt.Println("OK! ")
@ -254,6 +259,9 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
} }
gb := types.NewBlockWithHeader(gbh) gb := types.NewBlockWithHeader(gbh)
//gb.uncles = *new([]*types.Header)
//gb.transactions = *new(types.Transactions)
gb.Td = new(big.Int)
gb.Reward = new(big.Int) gb.Reward = new(big.Int)
testBlock := new(types.Block) testBlock := new(types.Block)

View File

@ -134,6 +134,15 @@ func StartEthereum(ethereum *eth.Ethereum) {
}) })
} }
func StartEthereumForTest(ethereum *eth.Ethereum) {
clilogger.Infoln("Starting ", ethereum.Name())
ethereum.StartForTest()
RegisterInterrupt(func(sig os.Signal) {
ethereum.Stop()
logger.Flush()
})
}
func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) { func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, SecretFile string, ExportDir string, NonInteractive bool) {
var err error var err error
switch { switch {

View File

@ -275,6 +275,17 @@ func (s *Ethereum) Start() error {
return nil return nil
} }
func (s *Ethereum) StartForTest() {
jsonlogger.LogJson(&logger.LogStarting{
ClientString: s.net.Name,
ProtocolVersion: ProtocolVersion,
})
// Start services
s.txPool.Start()
s.blockPool.Start()
}
func (self *Ethereum) SuggestPeer(nodeURL string) error { func (self *Ethereum) SuggestPeer(nodeURL string) error {
n, err := discover.ParseNode(nodeURL) n, err := discover.ParseNode(nodeURL)
if err != nil { if err != nil {