diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-19 17:25:27 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-19 17:25:27 +0800 |
commit | bd48690f63d07d9a0568f0d8092006ebaa12af5f (patch) | |
tree | 34fea6da378b5e101c51bde0bd811752caa532c0 | |
parent | 8730dfdcc2e2b40410a57385e4864d15f2f0336b (diff) | |
download | dexon-bd48690f63d07d9a0568f0d8092006ebaa12af5f.tar.gz dexon-bd48690f63d07d9a0568f0d8092006ebaa12af5f.tar.zst dexon-bd48690f63d07d9a0568f0d8092006ebaa12af5f.zip |
Testing different mining state
-rw-r--r-- | ethchain/dagger.go | 4 | ||||
-rw-r--r-- | ethchain/transaction_pool.go | 2 | ||||
-rw-r--r-- | ethminer/miner.go | 19 |
3 files changed, 12 insertions, 13 deletions
diff --git a/ethchain/dagger.go b/ethchain/dagger.go index 9d2df4069..18e53d3a8 100644 --- a/ethchain/dagger.go +++ b/ethchain/dagger.go @@ -29,14 +29,14 @@ func (pow *EasyPow) Search(block *Block, reactChan chan ethutil.React) []byte { for { select { case <-reactChan: - log.Println("[POW] Received reactor event; breaking out.") + ethutil.Config.Log.Infoln("[POW] Received reactor event; breaking out.") return nil default: i++ if i%1234567 == 0 { elapsed := time.Now().UnixNano() - start hashes := ((float64(1e9) / float64(elapsed)) * float64(i)) / 1000 - log.Println("[POW] Hashing @", int64(hashes), "khash") + ethutil.Config.Log.Infoln("[POW] Hashing @", int64(hashes), "khash") } sha := ethutil.Sha3Bin(big.NewInt(r.Int63()).Bytes()) diff --git a/ethchain/transaction_pool.go b/ethchain/transaction_pool.go index da77f32b3..796ec7c9a 100644 --- a/ethchain/transaction_pool.go +++ b/ethchain/transaction_pool.go @@ -131,7 +131,7 @@ func (pool *TxPool) ProcessTransaction(tx *Transaction, block *Block, toContract block.state.UpdateStateObject(sender) - log.Printf("[TXPL] Processed Tx %x\n", tx.Hash()) + ethutil.Config.Log.Infof("[TXPL] Processed Tx %x\n", tx.Hash()) // Notify all subscribers pool.Ethereum.Reactor().Post("newTx:post", tx) diff --git a/ethminer/miner.go b/ethminer/miner.go index 233a8bc32..294bc7b3d 100644 --- a/ethminer/miner.go +++ b/ethminer/miner.go @@ -5,7 +5,6 @@ import ( "github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethwire" - "log" ) type Miner struct { @@ -61,10 +60,10 @@ func (miner *Miner) listener() { select { case chanMessage := <-miner.reactChan: if block, ok := chanMessage.Resource.(*ethchain.Block); ok { - log.Println("[MINER] Got new block via Reactor") + ethutil.Config.Log.Infoln("[MINER] Got new block via Reactor") if bytes.Compare(miner.ethereum.BlockChain().CurrentBlock.Hash(), block.Hash()) == 0 { // TODO: Perhaps continue mining to get some uncle rewards - log.Println("[MINER] New top block found resetting state") + ethutil.Config.Log.Infoln("[MINER] New top block found resetting state") // Filter out which Transactions we have that were not in this block var newtxs []*ethchain.Transaction @@ -86,7 +85,7 @@ func (miner *Miner) listener() { } else { if bytes.Compare(block.PrevHash, miner.ethereum.BlockChain().CurrentBlock.PrevHash) == 0 { - log.Println("[MINER] Adding uncle block") + ethutil.Config.Log.Infoln("[MINER] Adding uncle block") miner.uncles = append(miner.uncles, block) //miner.ethereum.StateManager().Prepare(miner.block.State(), miner.block.State()) } @@ -94,7 +93,7 @@ func (miner *Miner) listener() { } if tx, ok := chanMessage.Resource.(*ethchain.Transaction); ok { - //log.Println("[MINER] Got new transaction from Reactor", tx) + //log.Infoln("[MINER] Got new transaction from Reactor", tx) found := false for _, ctx := range miner.txs { if found = bytes.Compare(ctx.Hash(), tx.Hash()) == 0; found { @@ -103,16 +102,16 @@ func (miner *Miner) listener() { } if found == false { - //log.Println("[MINER] We did not know about this transaction, adding") + //log.Infoln("[MINER] We did not know about this transaction, adding") miner.txs = append(miner.txs, tx) miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) miner.block.SetTransactions(miner.txs) } else { - //log.Println("[MINER] We already had this transaction, ignoring") + //log.Infoln("[MINER] We already had this transaction, ignoring") } } default: - log.Println("[MINER] Mining on block. Includes", len(miner.txs), "transactions") + ethutil.Config.Log.Infoln("[MINER] Mining on block. Includes", len(miner.txs), "transactions") // Apply uncles if len(miner.uncles) > 0 { @@ -128,12 +127,12 @@ func (miner *Miner) listener() { if miner.block.Nonce != nil { err := miner.ethereum.StateManager().ProcessBlock(miner.ethereum.StateManager().CurrentState(), miner.block, true) if err != nil { - log.Println(err) + ethutil.Config.Log.Infoln(err) miner.txs = []*ethchain.Transaction{} // Move this somewhere neat miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) } else { miner.ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{miner.block.Value().Val}) - log.Printf("[MINER] 🔨 Mined block %x\n", miner.block.Hash()) + ethutil.Config.Log.Infof("[MINER] 🔨 Mined block %x\n", miner.block.Hash()) miner.txs = []*ethchain.Transaction{} // Move this somewhere neat miner.block = miner.ethereum.BlockChain().NewBlock(miner.coinbase, miner.txs) |