aboutsummaryrefslogtreecommitdiffstats
path: root/miner/worker.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2016-02-13 08:40:44 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2016-02-13 20:14:02 +0800
commit987c1a595a6a318ac83b68e3b87812497070bf9b (patch)
tree30859d085d7533c7ad610eed8a186f88724eadfe /miner/worker.go
parentb05e472c076d30035233d6a8b5fb3360b236e3ff (diff)
downloadgo-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar.gz
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar.bz2
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar.lz
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar.xz
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.tar.zst
go-tangerine-987c1a595a6a318ac83b68e3b87812497070bf9b.zip
eth/filters: ✨ pending logs ✨
Pending logs are now filterable through the Go API. Filter API changed such that each filter type has it's own bucket and adding filter explicitly requires you specify the bucket to put it in.
Diffstat (limited to 'miner/worker.go')
-rw-r--r--miner/worker.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/miner/worker.go b/miner/worker.go
index 9c29d2250..81f7b16ac 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -243,7 +243,7 @@ func (self *worker) update() {
// Apply transaction to the pending state if we're not mining
if atomic.LoadInt32(&self.mining) == 0 {
self.currentMu.Lock()
- self.current.commitTransactions(types.Transactions{ev.Tx}, self.gasPrice, self.chain)
+ self.current.commitTransactions(self.mux, types.Transactions{ev.Tx}, self.gasPrice, self.chain)
self.currentMu.Unlock()
}
}
@@ -529,7 +529,7 @@ func (self *worker) commitNewWork() {
transactions := append(singleTxOwner, multiTxOwner...)
*/
- work.commitTransactions(transactions, self.gasPrice, self.chain)
+ work.commitTransactions(self.mux, transactions, self.gasPrice, self.chain)
self.eth.TxPool().RemoveTransactions(work.lowGasTxs)
// compute uncles for the new block.
@@ -588,8 +588,10 @@ func (self *worker) commitUncle(work *Work, uncle *types.Header) error {
return nil
}
-func (env *Work) commitTransactions(transactions types.Transactions, gasPrice *big.Int, bc *core.BlockChain) {
+func (env *Work) commitTransactions(mux *event.TypeMux, transactions types.Transactions, gasPrice *big.Int, bc *core.BlockChain) {
gp := new(core.GasPool).AddGas(env.header.GasLimit)
+
+ var coalescedLogs vm.Logs
for _, tx := range transactions {
// We can skip err. It has already been validated in the tx pool
from, _ := tx.From()
@@ -627,7 +629,7 @@ func (env *Work) commitTransactions(transactions types.Transactions, gasPrice *b
env.state.StartRecord(tx.Hash(), common.Hash{}, 0)
- err := env.commitTransaction(tx, bc, gp)
+ err, logs := env.commitTransaction(tx, bc, gp)
switch {
case core.IsGasLimitErr(err):
// ignore the transactor so no nonce errors will be thrown for this account
@@ -643,20 +645,25 @@ func (env *Work) commitTransactions(transactions types.Transactions, gasPrice *b
}
default:
env.tcount++
+ coalescedLogs = append(coalescedLogs, logs...)
}
}
+ if len(coalescedLogs) > 0 {
+ go mux.Post(core.PendingLogsEvent{Logs: coalescedLogs})
+ }
}
-func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) error {
+func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, gp *core.GasPool) (error, vm.Logs) {
snap := env.state.Copy()
- receipt, _, _, err := core.ApplyTransaction(bc, gp, env.state, env.header, tx, env.header.GasUsed)
+ receipt, logs, _, err := core.ApplyTransaction(bc, gp, env.state, env.header, tx, env.header.GasUsed)
if err != nil {
env.state.Set(snap)
- return err
+ return err, nil
}
env.txs = append(env.txs, tx)
env.receipts = append(env.receipts, receipt)
- return nil
+
+ return nil, logs
}
// TODO: remove or use