aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-12 03:47:34 +0800
committerobscuren <geffobscura@gmail.com>2015-05-12 03:47:34 +0800
commit97dd4551ef757c33fa33b5c06a0b15582e6a8af3 (patch)
treebe96435bcccaf6ac86308f98a2516af31ba1563c
parent0bedf1c3760a1042171fdfde0f119acb683c43ec (diff)
downloadgo-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar.gz
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar.bz2
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar.lz
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar.xz
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.tar.zst
go-tangerine-97dd4551ef757c33fa33b5c06a0b15582e6a8af3.zip
miner, cmd/geth: miner will not ignored owned account transactions
Miner does not ignore low gas txs from accounts that are owned.
-rw-r--r--cmd/geth/admin.go17
-rw-r--r--miner/worker.go56
2 files changed, 44 insertions, 29 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 17d711297..b0cb7507a 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -275,10 +275,19 @@ func (js *jsre) verbosity(call otto.FunctionCall) otto.Value {
}
func (js *jsre) startMining(call otto.FunctionCall) otto.Value {
- threads, err := call.Argument(0).ToInteger()
- if err != nil {
- fmt.Println(err)
- return otto.FalseValue()
+ var (
+ threads int64
+ err error
+ )
+
+ if len(call.ArgumentList) > 0 {
+ threads, err = call.Argument(0).ToInteger()
+ if err != nil {
+ fmt.Println(err)
+ return otto.FalseValue()
+ }
+ } else {
+ threads = 4
}
err = js.ethereum.StartMining(int(threads))
diff --git a/miner/worker.go b/miner/worker.go
index d801a9839..8698bb90d 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -21,21 +21,41 @@ import (
var jsonlogger = logger.NewJsonLogger()
+// Work holds the current work
+type Work struct {
+ Number uint64
+ Nonce uint64
+ MixDigest []byte
+ SeedHash []byte
+}
+
+// Agent can register themself with the worker
+type Agent interface {
+ Work() chan<- *types.Block
+ SetReturnCh(chan<- *types.Block)
+ Stop()
+ Start()
+ GetHashRate() int64
+}
+
+// environment is the workers current environment and holds
+// all of the current state information
type environment struct {
- totalUsedGas *big.Int
- state *state.StateDB
- coinbase *state.StateObject
- block *types.Block
- family *set.Set
- uncles *set.Set
- remove *set.Set
- tcount int
+ totalUsedGas *big.Int // total gas usage in the cycle
+ state *state.StateDB // apply state changes here
+ coinbase *state.StateObject // the miner's account
+ block *types.Block // the new block
+ family *set.Set // family set (used for checking uncles)
+ uncles *set.Set // uncle set
+ remove *set.Set // tx which will be removed
+ tcount int // tx count in cycle
ignoredTransactors *set.Set
lowGasTransactors *set.Set
ownedAccounts *set.Set
lowGasTxs types.Transactions
}
+// env returns a new environment for the current cycle
func env(block *types.Block, eth core.Backend) *environment {
state := state.New(block.Root(), eth.StateDb())
env := &environment{
@@ -50,21 +70,7 @@ func env(block *types.Block, eth core.Backend) *environment {
return env
}
-type Work struct {
- Number uint64
- Nonce uint64
- MixDigest []byte
- SeedHash []byte
-}
-
-type Agent interface {
- Work() chan<- *types.Block
- SetReturnCh(chan<- *types.Block)
- Stop()
- Start()
- GetHashRate() int64
-}
-
+// worker is the main object which takes care of applying messages to the new state
type worker struct {
mu sync.Mutex
@@ -375,8 +381,8 @@ func (self *worker) commitTransactions(transactions types.Transactions) {
// We can skip err. It has already been validated in the tx pool
from, _ := tx.From()
- // check if it falls within margin
- if tx.GasPrice().Cmp(self.gasPrice) < 0 {
+ // Check if it falls within margin. Txs from owned accounts are always processed.
+ if tx.GasPrice().Cmp(self.gasPrice) < 0 && !current.ownedAccounts.Has(from) {
// ignore the transaction and transactor. We ignore the transactor
// because nonce will fail after ignoring this transaction so there's
// no point