|
|
@ -6,7 +6,7 @@ import ( |
|
|
|
"github.com/ethereum/eth-go" |
|
|
|
"github.com/ethereum/eth-go" |
|
|
|
"github.com/ethereum/ethchain-go" |
|
|
|
"github.com/ethereum/ethchain-go" |
|
|
|
"github.com/ethereum/ethutil-go" |
|
|
|
"github.com/ethereum/ethutil-go" |
|
|
|
"github.com/ethereum/ethwire-go" |
|
|
|
_ "github.com/ethereum/ethwire-go" |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"os" |
|
|
|
"os" |
|
|
@ -84,12 +84,15 @@ func main() { |
|
|
|
ethereum.Start() |
|
|
|
ethereum.Start() |
|
|
|
|
|
|
|
|
|
|
|
if StartMining { |
|
|
|
if StartMining { |
|
|
|
log.Println("Dev Test Mining started") |
|
|
|
blockTime := time.Duration(15) |
|
|
|
|
|
|
|
log.Printf("Dev Test Mining started. Blocks found each %d seconds\n", blockTime) |
|
|
|
|
|
|
|
|
|
|
|
// Fake block mining. It broadcasts a new block every 5 seconds
|
|
|
|
// Fake block mining. It broadcasts a new block every 5 seconds
|
|
|
|
go func() { |
|
|
|
go func() { |
|
|
|
for { |
|
|
|
for { |
|
|
|
time.Sleep(5 * time.Second) |
|
|
|
txs := ethereum.TxPool.Flush() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time.Sleep(blockTime * time.Second) |
|
|
|
|
|
|
|
|
|
|
|
block := ethchain.CreateBlock( |
|
|
|
block := ethchain.CreateBlock( |
|
|
|
ethereum.BlockManager.BlockChain().LastBlock.State().Root, |
|
|
|
ethereum.BlockManager.BlockChain().LastBlock.State().Root, |
|
|
@ -98,11 +101,13 @@ func main() { |
|
|
|
big.NewInt(1), |
|
|
|
big.NewInt(1), |
|
|
|
big.NewInt(1), |
|
|
|
big.NewInt(1), |
|
|
|
"", |
|
|
|
"", |
|
|
|
ethereum.TxPool.Flush()) |
|
|
|
txs) |
|
|
|
|
|
|
|
err := ethereum.BlockManager.ProcessBlockWithState(block, block.State()) |
|
|
|
ethereum.BlockManager.ProcessBlockWithState(block, block.State()) |
|
|
|
if err != nil { |
|
|
|
ethereum.Broadcast(ethwire.MsgBlockTy, block.RlpData()) |
|
|
|
log.Println(err) |
|
|
|
log.Println("\n", block.String()) |
|
|
|
} else { |
|
|
|
|
|
|
|
log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}() |
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|