From a5b27bbc10d6a145152fc2629043c46ef4a9ca71 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Dec 2014 16:44:43 +0100 Subject: Improved and simplified wallet functions and behaviour --- miner/miner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index 589144c0c..f9b8a9c22 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -192,7 +192,7 @@ func (self *Miner) mine() { // Accumulate all valid transactions and apply them to the new state // Error may be ignored. It's not important during mining - receipts, txs, _, erroneous, err := blockManager.ProcessTransactions(coinbase, block.State(), block, block, transactions) + receipts, txs, _, erroneous, err := blockManager.ApplyTransactions(coinbase, block.State(), block, transactions, true) if err != nil { minerlogger.Debugln(err) } -- cgit v1.2.3 From 8dbca75d85553f2d9451ee563a919850f05ea1dd Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 4 Dec 2014 23:54:07 +0100 Subject: Skip mining on transactions that don't meet the min accepted gas price --- miner/miner.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index f9b8a9c22..c350eb1a8 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -228,23 +228,33 @@ func (self *Miner) mine() { func (self *Miner) finiliseTxs() types.Transactions { // Sort the transactions by nonce in case of odd network propagation - var txs types.Transactions + actualSize := len(self.localTxs) // See copy below + txs := make(types.Transactions, actualSize+self.eth.TxPool().Size()) 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 { + for i, ltx := range self.localTxs { 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) tx.Sign(key.PrivateKey()) - txs = append(txs, tx) + txs[i] = tx } - txs = append(txs, self.eth.TxPool().CurrentTransactions()...) - sort.Sort(types.TxByNonce{txs}) + // Faster than append + for _, tx := range self.eth.TxPool().CurrentTransactions() { + if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 { + txs[actualSize] = tx + actualSize++ + } + } + + newTransactions := make(types.Transactions, actualSize) + copy(newTransactions, txs[:actualSize]) + sort.Sort(types.TxByNonce{newTransactions}) - return txs + return newTransactions } -- cgit v1.2.3 From 9925916851c00323336e213fc18c83da5fceee94 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 5 Dec 2014 16:26:39 +0100 Subject: upped proto version and modified block pool --- miner/miner.go | 1 - 1 file changed, 1 deletion(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index c350eb1a8..4f677cbef 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -167,7 +167,6 @@ out: } func (self *Miner) reset() { - println("reset") close(self.powQuitCh) self.powQuitCh = make(chan struct{}) } -- cgit v1.2.3 From 1b98cbbfa4f587107fa15fccde7d22102ea4b1c0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 10 Dec 2014 16:45:16 +0100 Subject: Moved pow --- miner/miner.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index 4f677cbef..82a92cc20 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -29,6 +29,8 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/ethutil" + "github.com/ethereum/go-ethereum/pow" + "github.com/ethereum/go-ethereum/pow/ezp" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -59,7 +61,7 @@ type Miner struct { localTxs map[int]*LocalTx localTxId int - pow core.PoW + pow pow.PoW quitCh chan struct{} powQuitCh chan struct{} @@ -74,7 +76,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner { return &Miner{ eth: eth, powQuitCh: make(chan struct{}), - pow: &core.EasyPow{}, + pow: ezp.New(), mining: false, localTxs: make(map[int]*LocalTx), MinAcceptedGasPrice: big.NewInt(10000000000000), @@ -82,7 +84,7 @@ func New(coinbase []byte, eth *eth.Ethereum) *Miner { } } -func (self *Miner) GetPow() core.PoW { +func (self *Miner) GetPow() pow.PoW { return self.pow } -- cgit v1.2.3 From 5553e5aaed5c3f4e303b7d6671d2c92a45aa487e Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 10 Dec 2014 19:59:12 +0100 Subject: states moved to chain --- miner/miner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index 82a92cc20..dc69dddc0 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -232,7 +232,7 @@ func (self *Miner) finiliseTxs() types.Transactions { actualSize := len(self.localTxs) // See copy below txs := make(types.Transactions, actualSize+self.eth.TxPool().Size()) - state := self.eth.BlockManager().TransState() + state := self.eth.ChainManager().TransState() // XXX This has to change. Coinbase is, for new, same as key. key := self.eth.KeyManager() for i, ltx := range self.localTxs { -- cgit v1.2.3 From db494170dc819b1eb0d267b6e1ab36c6cfb63569 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Dec 2014 15:18:13 +0100 Subject: Created generic message (easy for testing) --- miner/miner.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'miner/miner.go') diff --git a/miner/miner.go b/miner/miner.go index dc69dddc0..f63096b63 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -237,8 +237,8 @@ func (self *Miner) finiliseTxs() types.Transactions { key := self.eth.KeyManager() for i, ltx := range self.localTxs { 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) + tx.SetNonce(state.GetNonce(self.Coinbase)) + state.SetNonce(self.Coinbase, tx.Nonce()+1) tx.Sign(key.PrivateKey()) @@ -247,7 +247,7 @@ func (self *Miner) finiliseTxs() types.Transactions { // Faster than append for _, tx := range self.eth.TxPool().CurrentTransactions() { - if tx.GasPrice.Cmp(self.MinAcceptedGasPrice) >= 0 { + if tx.GasPrice().Cmp(self.MinAcceptedGasPrice) >= 0 { txs[actualSize] = tx actualSize++ } -- cgit v1.2.3