aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2014-11-27 20:23:31 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2014-11-27 20:23:31 +0800
commitef7961b7d27be930a4d9dc81527a55497d3dea2e (patch)
tree5746b715b1b66c5767779e2e4ca66be345333e13 /miner
parentc17a3cb0ceec44c10bc84d05f0d81f08894c792c (diff)
parent8cf9ed0ea588e97f2baf0f834248727e8fbca18f (diff)
downloaddexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar.gz
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar.bz2
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar.lz
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar.xz
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.tar.zst
dexon-ef7961b7d27be930a4d9dc81527a55497d3dea2e.zip
Merge pull request #194 from ethereum/poc8
Update tests branch to PoC8
Diffstat (limited to 'miner')
-rw-r--r--miner/miner.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/miner/miner.go b/miner/miner.go
index a678a6895..795385424 100644
--- a/miner/miner.go
+++ b/miner/miner.go
@@ -29,8 +29,10 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethutil"
+ "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/chain"
+ "github.com/ethereum/go-ethereum/chain/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/wire"
@@ -44,7 +46,7 @@ type LocalTx struct {
Value string `json:"value"`
}
-func (self *LocalTx) Sign(key []byte) *chain.Transaction {
+func (self *LocalTx) Sign(key []byte) *types.Transaction {
return nil
}
@@ -54,7 +56,7 @@ type Miner struct {
eth *eth.Ethereum
events event.Subscription
- uncles chain.Blocks
+ uncles types.Blocks
localTxs map[int]*LocalTx
localTxId int
@@ -212,13 +214,15 @@ func (self *Miner) mine() {
nonce := self.pow.Search(block, self.powQuitCh)
if nonce != nil {
block.Nonce = nonce
- lchain := chain.NewChain(chain.Blocks{block})
+ lchain := chain.NewChain(types.Blocks{block})
_, err := chainMan.TestChain(lchain)
if err != nil {
minerlogger.Infoln(err)
} else {
- chainMan.InsertChain(lchain)
- //self.eth.EventMux().Post(chain.NewBlockEvent{block})
+ chainMan.InsertChain(lchain, func(block *types.Block, _ state.Messages) {
+ self.eth.EventMux().Post(chain.NewBlockEvent{block})
+ })
+
self.eth.Broadcast(wire.MsgBlockTy, []interface{}{block.Value().Val})
minerlogger.Infof("🔨 Mined block %x\n", block.Hash())
@@ -229,15 +233,15 @@ func (self *Miner) mine() {
}
}
-func (self *Miner) finiliseTxs() chain.Transactions {
+func (self *Miner) finiliseTxs() types.Transactions {
// Sort the transactions by nonce in case of odd network propagation
- var txs chain.Transactions
+ var txs types.Transactions
state := self.eth.BlockManager().TransState()
// XXX This has to change. Coinbase is, for new, same as key.
key := self.eth.KeyManager()
for _, ltx := range self.localTxs {
- tx := chain.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data)
+ tx := types.NewTransactionMessage(ltx.To, ethutil.Big(ltx.Value), ethutil.Big(ltx.Gas), ethutil.Big(ltx.GasPrice), ltx.Data)
tx.Nonce = state.GetNonce(self.Coinbase)
state.SetNonce(self.Coinbase, tx.Nonce+1)
@@ -247,7 +251,7 @@ func (self *Miner) finiliseTxs() chain.Transactions {
}
txs = append(txs, self.eth.TxPool().CurrentTransactions()...)
- sort.Sort(chain.TxByNonce{txs})
+ sort.Sort(types.TxByNonce{txs})
return txs
}