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
dea71556
Unverified
Commit
dea71556
authored
Jul 08, 2021
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
eth/gasprice, internal/ethapi, miner: minor feehistory fixes
parent
5441a8fa
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
100 deletions
+108
-100
feehistory.go
eth/gasprice/feehistory.go
+88
-81
feehistory_test.go
eth/gasprice/feehistory_test.go
+3
-2
api.go
internal/ethapi/api.go
+15
-15
worker.go
miner/worker.go
+2
-2
No files found.
eth/gasprice/feehistory.go
View file @
dea71556
This diff is collapsed.
Click to expand it.
eth/gasprice/feehistory_test.go
View file @
dea71556
...
...
@@ -18,6 +18,7 @@ package gasprice
import
(
"context"
"errors"
"math/big"
"testing"
...
...
@@ -37,7 +38,7 @@ func TestFeeHistory(t *testing.T) {
}{
{
false
,
0
,
0
,
10
,
30
,
nil
,
21
,
10
,
nil
},
{
false
,
0
,
0
,
10
,
30
,
[]
float64
{
0
,
10
},
21
,
10
,
nil
},
{
false
,
0
,
0
,
10
,
30
,
[]
float64
{
20
,
10
},
0
,
0
,
errInvalidPercentile
s
},
{
false
,
0
,
0
,
10
,
30
,
[]
float64
{
20
,
10
},
0
,
0
,
errInvalidPercentile
},
{
false
,
0
,
0
,
1000000000
,
30
,
nil
,
0
,
31
,
nil
},
{
false
,
0
,
0
,
1000000000
,
rpc
.
LatestBlockNumber
,
nil
,
0
,
33
,
nil
},
{
false
,
0
,
0
,
10
,
40
,
nil
,
0
,
0
,
errRequestBeyondHead
},
...
...
@@ -81,7 +82,7 @@ func TestFeeHistory(t *testing.T) {
if
len
(
ratio
)
!=
c
.
expCount
{
t
.
Fatalf
(
"Test case %d: gasUsedRatio array length mismatch, want %d, got %d"
,
i
,
c
.
expCount
,
len
(
ratio
))
}
if
err
!=
c
.
expErr
{
if
err
!=
c
.
expErr
&&
!
errors
.
Is
(
err
,
c
.
expErr
)
{
t
.
Fatalf
(
"Test case %d: error mismatch, want %v, got %v"
,
i
,
c
.
expErr
,
err
)
}
}
...
...
internal/ethapi/api.go
View file @
dea71556
...
...
@@ -80,28 +80,28 @@ func (s *PublicEthereumAPI) MaxPriorityFeePerGas(ctx context.Context) (*hexutil.
return
(
*
hexutil
.
Big
)(
tipcap
),
err
}
type
feeHistoryResult
s
struct
{
FirstBlock
rpc
.
BlockNumber
Reward
[][]
*
hexutil
.
Big
BaseFee
[]
*
hexutil
.
Big
GasUsedRatio
[]
float64
type
feeHistoryResult
struct
{
OldestBlock
rpc
.
BlockNumber
`json:"oldestBlock"`
Reward
[][]
*
hexutil
.
Big
`json:"reward,omitempty"`
BaseFee
[]
*
hexutil
.
Big
`json:"baseFeePerGas,omitempty"`
GasUsedRatio
[]
float64
`json:"gasUsedRatio"`
}
func
(
s
*
PublicEthereumAPI
)
FeeHistory
(
ctx
context
.
Context
,
blockCount
int
,
lastBlock
rpc
.
BlockNumber
,
rewardPercentiles
[]
float64
)
(
feeHistoryResults
,
error
)
{
firstBlock
,
reward
,
baseFee
,
gasUsedRatio
,
err
:=
s
.
b
.
FeeHistory
(
ctx
,
blockCount
,
lastBlock
,
rewardPercentiles
)
func
(
s
*
PublicEthereumAPI
)
FeeHistory
(
ctx
context
.
Context
,
blockCount
int
,
lastBlock
rpc
.
BlockNumber
,
rewardPercentiles
[]
float64
)
(
*
feeHistoryResult
,
error
)
{
oldest
,
reward
,
baseFee
,
gasUsed
,
err
:=
s
.
b
.
FeeHistory
(
ctx
,
blockCount
,
lastBlock
,
rewardPercentiles
)
if
err
!=
nil
{
return
feeHistoryResults
{}
,
err
return
nil
,
err
}
results
:=
feeHistoryResults
{
FirstBlock
:
firstBlock
,
GasUsedRatio
:
gasUsed
Ratio
,
results
:=
&
feeHistoryResult
{
OldestBlock
:
oldest
,
GasUsedRatio
:
gasUsed
,
}
if
reward
!=
nil
{
results
.
Reward
=
make
([][]
*
hexutil
.
Big
,
len
(
reward
))
for
j
,
w
:=
range
reward
{
results
.
Reward
[
j
]
=
make
([]
*
hexutil
.
Big
,
len
(
w
))
for
i
,
v
:=
range
w
{
results
.
Reward
[
j
][
i
]
=
(
*
hexutil
.
Big
)(
v
)
for
i
,
w
:=
range
reward
{
results
.
Reward
[
i
]
=
make
([]
*
hexutil
.
Big
,
len
(
w
))
for
j
,
v
:=
range
w
{
results
.
Reward
[
i
][
j
]
=
(
*
hexutil
.
Big
)(
v
)
}
}
}
...
...
miner/worker.go
View file @
dea71556
...
...
@@ -162,7 +162,7 @@ type worker struct {
pendingMu
sync
.
RWMutex
pendingTasks
map
[
common
.
Hash
]
*
task
snapshotMu
sync
.
RWMutex
// The lock used to protect the
block snapshot and state snapshot
snapshotMu
sync
.
RWMutex
// The lock used to protect the
snapshots below
snapshotBlock
*
types
.
Block
snapshotReceipts
types
.
Receipts
snapshotState
*
state
.
StateDB
...
...
@@ -745,7 +745,7 @@ func (w *worker) updateSnapshot() {
w
.
current
.
receipts
,
trie
.
NewStackTrie
(
nil
),
)
w
.
snapshotReceipts
=
w
.
current
.
receipts
w
.
snapshotReceipts
=
copyReceipts
(
w
.
current
.
receipts
)
w
.
snapshotState
=
w
.
current
.
state
.
Copy
()
}
...
...
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