Changed mining
This commit is contained in:
parent
c3ee0e92b8
commit
7f8f008253
10
ethereum.go
10
ethereum.go
@ -7,12 +7,10 @@ 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"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const Debug = true
|
const Debug = true
|
||||||
@ -78,8 +76,7 @@ func main() {
|
|||||||
ethereum.Start()
|
ethereum.Start()
|
||||||
|
|
||||||
if StartMining {
|
if StartMining {
|
||||||
blockTime := time.Duration(10)
|
log.Printf("Dev Test Mining started...\n")
|
||||||
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() {
|
||||||
@ -87,13 +84,12 @@ func main() {
|
|||||||
addr, _ := hex.DecodeString("82c3b0b72cf62f1a9ce97c64da8072efa28225d8")
|
addr, _ := hex.DecodeString("82c3b0b72cf62f1a9ce97c64da8072efa28225d8")
|
||||||
|
|
||||||
for {
|
for {
|
||||||
time.Sleep(blockTime * time.Second)
|
//time.Sleep(blockTime * time.Second)
|
||||||
|
|
||||||
txs := ethereum.TxPool.Flush()
|
txs := ethereum.TxPool.Flush()
|
||||||
block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
|
block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
|
||||||
|
|
||||||
nonce := pow.Search(block)
|
block.Nonce = pow.Search(block)
|
||||||
block.Nonce = nonce
|
|
||||||
|
|
||||||
err := ethereum.BlockManager.ProcessBlockWithState(block, block.State())
|
err := ethereum.BlockManager.ProcessBlockWithState(block, block.State())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user