File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -247,13 +247,6 @@ func (w *worker) setGasPrice(p *big.Int) {
247
247
w .gasPrice = p
248
248
}
249
249
250
- func (w * worker ) gasprice (pct int64 ) * big.Int {
251
- p := new (big.Int ).Set (w .gasPrice )
252
- p .Div (p , big .NewInt (100 ))
253
- p .Mul (p , big .NewInt (pct ))
254
- return p
255
- }
256
-
257
250
func (self * worker ) commitNewWork () {
258
251
self .mu .Lock ()
259
252
defer self .mu .Unlock ()
@@ -274,8 +267,9 @@ func (self *worker) commitNewWork() {
274
267
ignoredTransactors = set .New ()
275
268
)
276
269
277
- var pct int64 = 90
278
- minprice := self .gasprice (pct )
270
+ const pct = int64 (90 )
271
+ // calculate the minimal gas price the miner accepts when sorting out transactions.
272
+ minprice := gasprice (self .gasPrice , pct )
279
273
for _ , tx := range transactions {
280
274
// We can skip err. It has already been validated in the tx pool
281
275
from , _ := tx .From ()
@@ -411,3 +405,12 @@ func (self *worker) HashRate() int64 {
411
405
412
406
return tot
413
407
}
408
+
409
+ // gasprice calculates a reduced gas price based on the pct
410
+ // XXX Use big.Rat?
411
+ func gasprice (price * big.Int , pct int64 ) * big.Int {
412
+ p := new (big.Int ).Set (price )
413
+ p .Div (p , big .NewInt (100 ))
414
+ p .Mul (p , big .NewInt (pct ))
415
+ return p
416
+ }
You can’t perform that action at this time.
0 commit comments