mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-22 19:40:36 +00:00
miner: moved gasprice to non-method
This commit is contained in:
parent
13ddf20bd2
commit
a7705fc203
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user