Skip to content

Commit

Permalink
miner: enable private transactions in worker
Browse files Browse the repository at this point in the history
  • Loading branch information
markya0616 committed Sep 1, 2017
1 parent f4e8d3b commit 981ee55
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func newWorker(config *params.ChainConfig, engine consensus.Engine, coinbase com
fullValidation: false,
}

if !config.IsQuorum {
if _, ok := engine.(consensus.Istanbul); ok || !config.IsQuorum {
// Subscribe TxPreEvent for tx pool
worker.txSub = eth.TxPool().SubscribeTxPreEvent(worker.txCh)
// Subscribe events for blockchain
Expand Down Expand Up @@ -312,6 +312,7 @@ func (self *worker) wait() {
go self.mux.Post(core.NewMinedBlockEvent{Block: block})
} else {
work.state.CommitTo(self.chainDb, self.config.IsEIP158(block.Number()))
work.privateState.CommitTo(self.chainDb, self.config.IsEIP158(block.Number()))
stat, err := self.chain.WriteBlock(block)
if err != nil {
log.Error("Failed writing block to chain", "err", err)
Expand Down Expand Up @@ -607,14 +608,20 @@ func (env *Work) commitTransactions(mux *event.TypeMux, txs *types.TransactionsB

func (env *Work) commitTransaction(tx *types.Transaction, bc *core.BlockChain, coinbase common.Address, gp *core.GasPool) (error, []*types.Log) {
snap := env.state.Snapshot()
privateSnap := env.privateState.Snapshot()

receipt, _, _, err := core.ApplyTransaction(env.config, bc, &coinbase, gp, env.state, env.privateState, env.header, tx, env.header.GasUsed, vm.Config{})
receipt, privateReceipt, _, err := core.ApplyTransaction(env.config, bc, &coinbase, gp, env.state, env.privateState, env.header, tx, env.header.GasUsed, vm.Config{})
if err != nil {
env.state.RevertToSnapshot(snap)
env.privateState.RevertToSnapshot(privateSnap)
return err, nil
}
env.txs = append(env.txs, tx)
env.receipts = append(env.receipts, receipt)

return nil, receipt.Logs
logs := receipt.Logs
if privateReceipt != nil {
logs = append(receipt.Logs, privateReceipt.Logs...)
}
return nil, logs
}

0 comments on commit 981ee55

Please sign in to comment.