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
0b284f6c
Unverified
Commit
0b284f6c
authored
Jan 23, 2020
by
Martin Holst Swende
Committed by
GitHub
Jan 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth/retesteth: use canon head instead of keeping alternate count (#20572)
parent
8a5c8134
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
retesteth.go
cmd/geth/retesteth.go
+14
-11
No files found.
cmd/geth/retesteth.go
View file @
0b284f6c
...
...
@@ -110,7 +110,6 @@ type RetestethAPI struct {
genesisHash
common
.
Hash
engine
*
NoRewardEngine
blockchain
*
core
.
BlockChain
blockNumber
uint64
txMap
map
[
common
.
Address
]
map
[
uint64
]
*
types
.
Transaction
// Sender -> Nonce -> Transaction
txSenders
map
[
common
.
Address
]
struct
{}
// Set of transaction senders
blockInterval
uint64
...
...
@@ -411,7 +410,6 @@ func (api *RetestethAPI) SetChainParams(ctx context.Context, chainParams ChainPa
api
.
engine
=
engine
api
.
blockchain
=
blockchain
api
.
db
=
state
.
NewDatabase
(
api
.
ethDb
)
api
.
blockNumber
=
0
api
.
txMap
=
make
(
map
[
common
.
Address
]
map
[
uint64
]
*
types
.
Transaction
)
api
.
txSenders
=
make
(
map
[
common
.
Address
]
struct
{})
api
.
blockInterval
=
0
...
...
@@ -424,7 +422,7 @@ func (api *RetestethAPI) SendRawTransaction(ctx context.Context, rawTx hexutil.B
// Return nil is not by mistake - some tests include sending transaction where gasLimit overflows uint64
return
common
.
Hash
{},
nil
}
signer
:=
types
.
MakeSigner
(
api
.
chainConfig
,
big
.
NewInt
(
int64
(
api
.
blockNumber
)))
signer
:=
types
.
MakeSigner
(
api
.
chainConfig
,
big
.
NewInt
(
int64
(
api
.
currentNumber
()
)))
sender
,
err
:=
types
.
Sender
(
signer
,
tx
)
if
err
!=
nil
{
return
common
.
Hash
{},
err
...
...
@@ -450,9 +448,17 @@ func (api *RetestethAPI) MineBlocks(ctx context.Context, number uint64) (bool, e
return
true
,
nil
}
func
(
api
*
RetestethAPI
)
currentNumber
()
uint64
{
if
current
:=
api
.
blockchain
.
CurrentBlock
();
current
!=
nil
{
return
current
.
NumberU64
()
}
return
0
}
func
(
api
*
RetestethAPI
)
mineBlock
()
error
{
parentHash
:=
rawdb
.
ReadCanonicalHash
(
api
.
ethDb
,
api
.
blockNumber
)
parent
:=
rawdb
.
ReadBlock
(
api
.
ethDb
,
parentHash
,
api
.
blockNumber
)
number
:=
api
.
currentNumber
()
parentHash
:=
rawdb
.
ReadCanonicalHash
(
api
.
ethDb
,
number
)
parent
:=
rawdb
.
ReadBlock
(
api
.
ethDb
,
parentHash
,
number
)
var
timestamp
uint64
if
api
.
blockInterval
==
0
{
timestamp
=
uint64
(
time
.
Now
()
.
Unix
())
...
...
@@ -462,7 +468,7 @@ func (api *RetestethAPI) mineBlock() error {
gasLimit
:=
core
.
CalcGasLimit
(
parent
,
9223372036854775807
,
9223372036854775807
)
header
:=
&
types
.
Header
{
ParentHash
:
parent
.
Hash
(),
Number
:
big
.
NewInt
(
int64
(
api
.
blockN
umber
+
1
)),
Number
:
big
.
NewInt
(
int64
(
n
umber
+
1
)),
GasLimit
:
gasLimit
,
Extra
:
api
.
extraData
,
Time
:
timestamp
,
...
...
@@ -548,8 +554,7 @@ func (api *RetestethAPI) importBlock(block *types.Block) error {
if
_
,
err
:=
api
.
blockchain
.
InsertChain
([]
*
types
.
Block
{
block
});
err
!=
nil
{
return
err
}
api
.
blockNumber
=
block
.
NumberU64
()
fmt
.
Printf
(
"Imported block %d
\n
"
,
block
.
NumberU64
())
fmt
.
Printf
(
"Imported block %d, head is %d
\n
"
,
block
.
NumberU64
(),
api
.
currentNumber
())
return
nil
}
...
...
@@ -574,7 +579,6 @@ func (api *RetestethAPI) RewindToBlock(ctx context.Context, newHead uint64) (boo
if
err
:=
api
.
blockchain
.
SetHead
(
newHead
);
err
!=
nil
{
return
false
,
err
}
api
.
blockNumber
=
newHead
return
true
,
nil
}
...
...
@@ -594,8 +598,7 @@ func (api *RetestethAPI) GetLogHash(ctx context.Context, txHash common.Hash) (co
}
func
(
api
*
RetestethAPI
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
{
//fmt.Printf("BlockNumber, response: %d\n", api.blockNumber)
return
api
.
blockNumber
,
nil
return
api
.
currentNumber
(),
nil
}
func
(
api
*
RetestethAPI
)
GetBlockByNumber
(
ctx
context
.
Context
,
blockNr
math
.
HexOrDecimal64
,
fullTx
bool
)
(
map
[
string
]
interface
{},
error
)
{
...
...
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