Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a7705fc2
Commit
a7705fc2
authored
May 09, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
miner: moved gasprice to non-method
parent
13ddf20b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
worker.go
miner/worker.go
+12
-9
No files found.
miner/worker.go
View file @
a7705fc2
...
@@ -247,13 +247,6 @@ func (w *worker) setGasPrice(p *big.Int) {
...
@@ -247,13 +247,6 @@ func (w *worker) setGasPrice(p *big.Int) {
w
.
gasPrice
=
p
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
()
{
func
(
self
*
worker
)
commitNewWork
()
{
self
.
mu
.
Lock
()
self
.
mu
.
Lock
()
defer
self
.
mu
.
Unlock
()
defer
self
.
mu
.
Unlock
()
...
@@ -274,8 +267,9 @@ func (self *worker) commitNewWork() {
...
@@ -274,8 +267,9 @@ func (self *worker) commitNewWork() {
ignoredTransactors
=
set
.
New
()
ignoredTransactors
=
set
.
New
()
)
)
var
pct
int64
=
90
const
pct
=
int64
(
90
)
minprice
:=
self
.
gasprice
(
pct
)
// calculate the minimal gas price the miner accepts when sorting out transactions.
minprice
:=
gasprice
(
self
.
gasPrice
,
pct
)
for
_
,
tx
:=
range
transactions
{
for
_
,
tx
:=
range
transactions
{
// We can skip err. It has already been validated in the tx pool
// We can skip err. It has already been validated in the tx pool
from
,
_
:=
tx
.
From
()
from
,
_
:=
tx
.
From
()
...
@@ -411,3 +405,12 @@ func (self *worker) HashRate() int64 {
...
@@ -411,3 +405,12 @@ func (self *worker) HashRate() int64 {
return
tot
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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment