aboutsummaryrefslogtreecommitdiffstats
path: root/miner
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-05-09 18:13:46 +0800
committerobscuren <geffobscura@gmail.com>2015-05-09 18:13:46 +0800
commita7705fc2037836f037de5e5ea5aef8475424a1be (patch)
tree0863689f53b7316dea090714485c3d2e4a392674 /miner
parent13ddf20bd20707141309fbfa969183a7afbe5a80 (diff)
downloadgo-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar.gz
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar.bz2
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar.lz
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar.xz
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.tar.zst
go-tangerine-a7705fc2037836f037de5e5ea5aef8475424a1be.zip
miner: moved gasprice to non-method
Diffstat (limited to 'miner')
-rw-r--r--miner/worker.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/miner/worker.go b/miner/worker.go
index bb8b70c86..7adf298ed 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -247,13 +247,6 @@ func (w *worker) setGasPrice(p *big.Int) {
w.gasPrice = p
}
-func (w *worker) gasprice(pct int64) *big.Int {
- p := new(big.Int).Set(w.gasPrice)
- p.Div(p, big.NewInt(100))
- p.Mul(p, big.NewInt(pct))
- return p
-}
-
func (self *worker) commitNewWork() {
self.mu.Lock()
defer self.mu.Unlock()
@@ -274,8 +267,9 @@ func (self *worker) commitNewWork() {
ignoredTransactors = set.New()
)
- var pct int64 = 90
- minprice := self.gasprice(pct)
+ const pct = int64(90)
+ // calculate the minimal gas price the miner accepts when sorting out transactions.
+ minprice := gasprice(self.gasPrice, pct)
for _, tx := range transactions {
// We can skip err. It has already been validated in the tx pool
from, _ := tx.From()
@@ -411,3 +405,12 @@ func (self *worker) HashRate() int64 {
return tot
}
+
+// gasprice calculates a reduced gas price based on the pct
+// XXX Use big.Rat?
+func gasprice(price *big.Int, pct int64) *big.Int {
+ p := new(big.Int).Set(price)
+ p.Div(p, big.NewInt(100))
+ p.Mul(p, big.NewInt(pct))
+ return p
+}