good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
f751c6ed
Unverified
Commit
f751c6ed
authored
Aug 28, 2018
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
miner: track uncles more aggressively
parent
c1c003e4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
miner/worker.go
+15
-17
15 additions, 17 deletions
miner/worker.go
miner/worker_test.go
+48
-34
48 additions, 34 deletions
miner/worker_test.go
with
63 additions
and
51 deletions
miner/worker.go
+
15
−
17
View file @
f751c6ed
...
@@ -18,7 +18,7 @@ package miner
...
@@ -18,7 +18,7 @@ package miner
import
(
import
(
"bytes"
"bytes"
"
fmt
"
"
errors
"
"math/big"
"math/big"
"sync"
"sync"
"sync/atomic"
"sync/atomic"
...
@@ -615,13 +615,16 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
...
@@ -615,13 +615,16 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
func
(
w
*
worker
)
commitUncle
(
env
*
environment
,
uncle
*
types
.
Header
)
error
{
func
(
w
*
worker
)
commitUncle
(
env
*
environment
,
uncle
*
types
.
Header
)
error
{
hash
:=
uncle
.
Hash
()
hash
:=
uncle
.
Hash
()
if
env
.
uncles
.
Contains
(
hash
)
{
if
env
.
uncles
.
Contains
(
hash
)
{
return
fmt
.
Errorf
(
"uncle not unique"
)
return
errors
.
New
(
"uncle not unique"
)
}
if
env
.
header
.
ParentHash
==
uncle
.
ParentHash
{
return
errors
.
New
(
"uncle is sibling"
)
}
}
if
!
env
.
ancestors
.
Contains
(
uncle
.
ParentHash
)
{
if
!
env
.
ancestors
.
Contains
(
uncle
.
ParentHash
)
{
return
fmt
.
Errorf
(
"uncle's parent unknown
(%x)"
,
uncle
.
ParentHash
[
0
:
4
]
)
return
errors
.
New
(
"uncle's parent unknown
"
)
}
}
if
env
.
family
.
Contains
(
hash
)
{
if
env
.
family
.
Contains
(
hash
)
{
return
fmt
.
Errorf
(
"uncle already in
family (%x)"
,
hash
)
return
errors
.
New
(
"uncle already in
cluded"
)
}
}
env
.
uncles
.
Add
(
uncle
.
Hash
())
env
.
uncles
.
Add
(
uncle
.
Hash
())
return
nil
return
nil
...
@@ -847,29 +850,24 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) {
...
@@ -847,29 +850,24 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool) {
if
w
.
config
.
DAOForkSupport
&&
w
.
config
.
DAOForkBlock
!=
nil
&&
w
.
config
.
DAOForkBlock
.
Cmp
(
header
.
Number
)
==
0
{
if
w
.
config
.
DAOForkSupport
&&
w
.
config
.
DAOForkBlock
!=
nil
&&
w
.
config
.
DAOForkBlock
.
Cmp
(
header
.
Number
)
==
0
{
misc
.
ApplyDAOHardFork
(
env
.
state
)
misc
.
ApplyDAOHardFork
(
env
.
state
)
}
}
// Accumulate the uncles for the current block
// compute uncles for the new block.
for
hash
,
uncle
:=
range
w
.
possibleUncles
{
var
(
if
uncle
.
NumberU64
()
+
staleThreshold
<=
header
.
Number
.
Uint64
()
{
uncles
[]
*
types
.
Header
delete
(
w
.
possibleUncles
,
hash
)
badUncles
[]
common
.
Hash
}
)
}
uncles
:=
make
([]
*
types
.
Header
,
0
,
2
)
for
hash
,
uncle
:=
range
w
.
possibleUncles
{
for
hash
,
uncle
:=
range
w
.
possibleUncles
{
if
len
(
uncles
)
==
2
{
if
len
(
uncles
)
==
2
{
break
break
}
}
if
err
:=
w
.
commitUncle
(
env
,
uncle
.
Header
());
err
!=
nil
{
if
err
:=
w
.
commitUncle
(
env
,
uncle
.
Header
());
err
!=
nil
{
log
.
Trace
(
"Bad uncle found and will be removed"
,
"hash"
,
hash
)
log
.
Trace
(
"Possible uncle rejected"
,
"hash"
,
hash
,
"reason"
,
err
)
log
.
Trace
(
fmt
.
Sprint
(
uncle
))
badUncles
=
append
(
badUncles
,
hash
)
}
else
{
}
else
{
log
.
Debug
(
"Committing new uncle to block"
,
"hash"
,
hash
)
log
.
Debug
(
"Committing new uncle to block"
,
"hash"
,
hash
)
uncles
=
append
(
uncles
,
uncle
.
Header
())
uncles
=
append
(
uncles
,
uncle
.
Header
())
}
}
}
}
for
_
,
hash
:=
range
badUncles
{
delete
(
w
.
possibleUncles
,
hash
)
}
if
!
noempty
{
if
!
noempty
{
// Create an empty block based on temporary copied state for sealing in advance without waiting block
// Create an empty block based on temporary copied state for sealing in advance without waiting block
...
...
This diff is collapsed.
Click to expand it.
miner/worker_test.go
+
48
−
34
View file @
f751c6ed
...
@@ -45,8 +45,8 @@ var (
...
@@ -45,8 +45,8 @@ var (
testBankAddress
=
crypto
.
PubkeyToAddress
(
testBankKey
.
PublicKey
)
testBankAddress
=
crypto
.
PubkeyToAddress
(
testBankKey
.
PublicKey
)
testBankFunds
=
big
.
NewInt
(
1000000000000000000
)
testBankFunds
=
big
.
NewInt
(
1000000000000000000
)
acc1
Key
,
_
=
crypto
.
GenerateKey
()
testUser
Key
,
_
=
crypto
.
GenerateKey
()
acc1
Addr
=
crypto
.
PubkeyToAddress
(
acc1
Key
.
PublicKey
)
testUser
Addr
ess
=
crypto
.
PubkeyToAddress
(
testUser
Key
.
PublicKey
)
// Test transactions
// Test transactions
pendingTxs
[]
*
types
.
Transaction
pendingTxs
[]
*
types
.
Transaction
...
@@ -62,9 +62,9 @@ func init() {
...
@@ -62,9 +62,9 @@ func init() {
Period
:
10
,
Period
:
10
,
Epoch
:
30000
,
Epoch
:
30000
,
}
}
tx1
,
_
:=
types
.
SignTx
(
types
.
NewTransaction
(
0
,
acc1
Addr
,
big
.
NewInt
(
1000
),
params
.
TxGas
,
nil
,
nil
),
types
.
HomesteadSigner
{},
testBankKey
)
tx1
,
_
:=
types
.
SignTx
(
types
.
NewTransaction
(
0
,
testUser
Addr
ess
,
big
.
NewInt
(
1000
),
params
.
TxGas
,
nil
,
nil
),
types
.
HomesteadSigner
{},
testBankKey
)
pendingTxs
=
append
(
pendingTxs
,
tx1
)
pendingTxs
=
append
(
pendingTxs
,
tx1
)
tx2
,
_
:=
types
.
SignTx
(
types
.
NewTransaction
(
1
,
acc1
Addr
,
big
.
NewInt
(
1000
),
params
.
TxGas
,
nil
,
nil
),
types
.
HomesteadSigner
{},
testBankKey
)
tx2
,
_
:=
types
.
SignTx
(
types
.
NewTransaction
(
1
,
testUser
Addr
ess
,
big
.
NewInt
(
1000
),
params
.
TxGas
,
nil
,
nil
),
types
.
HomesteadSigner
{},
testBankKey
)
newTxs
=
append
(
newTxs
,
tx2
)
newTxs
=
append
(
newTxs
,
tx2
)
}
}
...
@@ -77,7 +77,7 @@ type testWorkerBackend struct {
...
@@ -77,7 +77,7 @@ type testWorkerBackend struct {
uncleBlock
*
types
.
Block
uncleBlock
*
types
.
Block
}
}
func
newTestWorkerBackend
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
*
testWorkerBackend
{
func
newTestWorkerBackend
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
,
n
int
)
*
testWorkerBackend
{
var
(
var
(
db
=
ethdb
.
NewMemDatabase
()
db
=
ethdb
.
NewMemDatabase
()
gspec
=
core
.
Genesis
{
gspec
=
core
.
Genesis
{
...
@@ -92,14 +92,28 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
...
@@ -92,14 +92,28 @@ func newTestWorkerBackend(t *testing.T, chainConfig *params.ChainConfig, engine
copy
(
gspec
.
ExtraData
[
32
:
],
testBankAddress
[
:
])
copy
(
gspec
.
ExtraData
[
32
:
],
testBankAddress
[
:
])
case
*
ethash
.
Ethash
:
case
*
ethash
.
Ethash
:
default
:
default
:
t
.
Fatal
(
"unexpect consensus engine type
"
)
t
.
Fatal
f
(
"unexpect
ed
consensus engine type
: %T"
,
engine
)
}
}
genesis
:=
gspec
.
MustCommit
(
db
)
genesis
:=
gspec
.
MustCommit
(
db
)
chain
,
_
:=
core
.
NewBlockChain
(
db
,
nil
,
gspec
.
Config
,
engine
,
vm
.
Config
{})
chain
,
_
:=
core
.
NewBlockChain
(
db
,
nil
,
gspec
.
Config
,
engine
,
vm
.
Config
{})
txpool
:=
core
.
NewTxPool
(
testTxPoolConfig
,
chainConfig
,
chain
)
txpool
:=
core
.
NewTxPool
(
testTxPoolConfig
,
chainConfig
,
chain
)
blocks
,
_
:=
core
.
GenerateChain
(
chainConfig
,
genesis
,
engine
,
db
,
1
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{
gen
.
SetCoinbase
(
acc1Addr
)
// Generate a small n-block chain and an uncle block for it
if
n
>
0
{
blocks
,
_
:=
core
.
GenerateChain
(
chainConfig
,
genesis
,
engine
,
db
,
n
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{
gen
.
SetCoinbase
(
testBankAddress
)
})
if
_
,
err
:=
chain
.
InsertChain
(
blocks
);
err
!=
nil
{
t
.
Fatalf
(
"failed to insert origin chain: %v"
,
err
)
}
}
parent
:=
genesis
if
n
>
0
{
parent
=
chain
.
GetBlockByHash
(
chain
.
CurrentBlock
()
.
ParentHash
())
}
blocks
,
_
:=
core
.
GenerateChain
(
chainConfig
,
parent
,
engine
,
db
,
1
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{
gen
.
SetCoinbase
(
testUserAddress
)
})
})
return
&
testWorkerBackend
{
return
&
testWorkerBackend
{
...
@@ -116,8 +130,8 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
...
@@ -116,8 +130,8 @@ func (b *testWorkerBackend) PostChainEvents(events []interface{}) {
b
.
chain
.
PostChainEvents
(
events
,
nil
)
b
.
chain
.
PostChainEvents
(
events
,
nil
)
}
}
func
newTestWorker
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
(
*
worker
,
*
testWorkerBackend
)
{
func
newTestWorker
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
,
blocks
int
)
(
*
worker
,
*
testWorkerBackend
)
{
backend
:=
newTestWorkerBackend
(
t
,
chainConfig
,
engine
)
backend
:=
newTestWorkerBackend
(
t
,
chainConfig
,
engine
,
blocks
)
backend
.
txPool
.
AddLocals
(
pendingTxs
)
backend
.
txPool
.
AddLocals
(
pendingTxs
)
w
:=
newWorker
(
chainConfig
,
engine
,
backend
,
new
(
event
.
TypeMux
),
time
.
Second
)
w
:=
newWorker
(
chainConfig
,
engine
,
backend
,
new
(
event
.
TypeMux
),
time
.
Second
)
w
.
setEtherbase
(
testBankAddress
)
w
.
setEtherbase
(
testBankAddress
)
...
@@ -134,24 +148,24 @@ func TestPendingStateAndBlockClique(t *testing.T) {
...
@@ -134,24 +148,24 @@ func TestPendingStateAndBlockClique(t *testing.T) {
func
testPendingStateAndBlock
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
func
testPendingStateAndBlock
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
defer
engine
.
Close
()
defer
engine
.
Close
()
w
,
b
:=
newTestWorker
(
t
,
chainConfig
,
engine
)
w
,
b
:=
newTestWorker
(
t
,
chainConfig
,
engine
,
0
)
defer
w
.
close
()
defer
w
.
close
()
// Ensure snapshot has been updated.
// Ensure snapshot has been updated.
time
.
Sleep
(
100
*
time
.
Millisecond
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
block
,
state
:=
w
.
pending
()
block
,
state
:=
w
.
pending
()
if
block
.
NumberU64
()
!=
1
{
if
block
.
NumberU64
()
!=
1
{
t
.
Errorf
(
"block number mismatch
,
ha
s
%d, want %d"
,
block
.
NumberU64
(),
1
)
t
.
Errorf
(
"block number mismatch
:
ha
ve
%d, want %d"
,
block
.
NumberU64
(),
1
)
}
}
if
balance
:=
state
.
GetBalance
(
acc1
Addr
);
balance
.
Cmp
(
big
.
NewInt
(
1000
))
!=
0
{
if
balance
:=
state
.
GetBalance
(
testUser
Addr
ess
);
balance
.
Cmp
(
big
.
NewInt
(
1000
))
!=
0
{
t
.
Errorf
(
"account balance mismatch
,
ha
s
%d, want %d"
,
balance
,
1000
)
t
.
Errorf
(
"account balance mismatch
:
ha
ve
%d, want %d"
,
balance
,
1000
)
}
}
b
.
txPool
.
AddLocals
(
newTxs
)
b
.
txPool
.
AddLocals
(
newTxs
)
// Ensure the new tx events has been processed
// Ensure the new tx events has been processed
time
.
Sleep
(
100
*
time
.
Millisecond
)
time
.
Sleep
(
100
*
time
.
Millisecond
)
block
,
state
=
w
.
pending
()
block
,
state
=
w
.
pending
()
if
balance
:=
state
.
GetBalance
(
acc1
Addr
);
balance
.
Cmp
(
big
.
NewInt
(
2000
))
!=
0
{
if
balance
:=
state
.
GetBalance
(
testUser
Addr
ess
);
balance
.
Cmp
(
big
.
NewInt
(
2000
))
!=
0
{
t
.
Errorf
(
"account balance mismatch
,
ha
s
%d, want %d"
,
balance
,
2000
)
t
.
Errorf
(
"account balance mismatch
:
ha
ve
%d, want %d"
,
balance
,
2000
)
}
}
}
}
...
@@ -165,7 +179,7 @@ func TestEmptyWorkClique(t *testing.T) {
...
@@ -165,7 +179,7 @@ func TestEmptyWorkClique(t *testing.T) {
func
testEmptyWork
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
func
testEmptyWork
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
defer
engine
.
Close
()
defer
engine
.
Close
()
w
,
_
:=
newTestWorker
(
t
,
chainConfig
,
engine
)
w
,
_
:=
newTestWorker
(
t
,
chainConfig
,
engine
,
0
)
defer
w
.
close
()
defer
w
.
close
()
var
(
var
(
...
@@ -179,10 +193,10 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
...
@@ -179,10 +193,10 @@ func testEmptyWork(t *testing.T, chainConfig *params.ChainConfig, engine consens
receiptLen
,
balance
=
1
,
big
.
NewInt
(
1000
)
receiptLen
,
balance
=
1
,
big
.
NewInt
(
1000
)
}
}
if
len
(
task
.
receipts
)
!=
receiptLen
{
if
len
(
task
.
receipts
)
!=
receiptLen
{
t
.
Errorf
(
"receipt number mismatch ha
s
%d, want %d"
,
len
(
task
.
receipts
),
receiptLen
)
t
.
Errorf
(
"receipt number mismatch
:
ha
ve
%d, want %d"
,
len
(
task
.
receipts
),
receiptLen
)
}
}
if
task
.
state
.
GetBalance
(
acc1
Addr
)
.
Cmp
(
balance
)
!=
0
{
if
task
.
state
.
GetBalance
(
testUser
Addr
ess
)
.
Cmp
(
balance
)
!=
0
{
t
.
Errorf
(
"account balance mismatch ha
s
%d, want %d"
,
task
.
state
.
GetBalance
(
acc1
Addr
),
balance
)
t
.
Errorf
(
"account balance mismatch
:
ha
ve
%d, want %d"
,
task
.
state
.
GetBalance
(
testUser
Addr
ess
),
balance
)
}
}
}
}
...
@@ -219,19 +233,19 @@ func TestStreamUncleBlock(t *testing.T) {
...
@@ -219,19 +233,19 @@ func TestStreamUncleBlock(t *testing.T) {
ethash
:=
ethash
.
NewFaker
()
ethash
:=
ethash
.
NewFaker
()
defer
ethash
.
Close
()
defer
ethash
.
Close
()
w
,
b
:=
newTestWorker
(
t
,
ethashChainConfig
,
ethash
)
w
,
b
:=
newTestWorker
(
t
,
ethashChainConfig
,
ethash
,
1
)
defer
w
.
close
()
defer
w
.
close
()
var
taskCh
=
make
(
chan
struct
{})
var
taskCh
=
make
(
chan
struct
{})
taskIndex
:=
0
taskIndex
:=
0
w
.
newTaskHook
=
func
(
task
*
task
)
{
w
.
newTaskHook
=
func
(
task
*
task
)
{
if
task
.
block
.
NumberU64
()
==
1
{
if
task
.
block
.
NumberU64
()
==
2
{
if
taskIndex
==
2
{
if
taskIndex
==
2
{
ha
s
:=
task
.
block
.
Header
()
.
UncleHash
ha
ve
:=
task
.
block
.
Header
()
.
UncleHash
want
:=
types
.
CalcUncleHash
([]
*
types
.
Header
{
b
.
uncleBlock
.
Header
()})
want
:=
types
.
CalcUncleHash
([]
*
types
.
Header
{
b
.
uncleBlock
.
Header
()})
if
ha
s
!=
want
{
if
ha
ve
!=
want
{
t
.
Errorf
(
"uncle hash mismatch
,
ha
s
%s, want %s"
,
ha
s
.
Hex
(),
want
.
Hex
())
t
.
Errorf
(
"uncle hash mismatch
:
ha
ve
%s, want %s"
,
ha
ve
.
Hex
(),
want
.
Hex
())
}
}
}
}
taskCh
<-
struct
{}{}
taskCh
<-
struct
{}{}
...
@@ -248,12 +262,12 @@ func TestStreamUncleBlock(t *testing.T) {
...
@@ -248,12 +262,12 @@ func TestStreamUncleBlock(t *testing.T) {
// Ensure worker has finished initialization
// Ensure worker has finished initialization
for
{
for
{
b
:=
w
.
pendingBlock
()
b
:=
w
.
pendingBlock
()
if
b
!=
nil
&&
b
.
NumberU64
()
==
1
{
if
b
!=
nil
&&
b
.
NumberU64
()
==
2
{
break
break
}
}
}
}
w
.
start
()
w
.
start
()
// Ignore the first two works
// Ignore the first two works
for
i
:=
0
;
i
<
2
;
i
+=
1
{
for
i
:=
0
;
i
<
2
;
i
+=
1
{
select
{
select
{
...
@@ -282,7 +296,7 @@ func TestRegenerateMiningBlockClique(t *testing.T) {
...
@@ -282,7 +296,7 @@ func TestRegenerateMiningBlockClique(t *testing.T) {
func
testRegenerateMiningBlock
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
func
testRegenerateMiningBlock
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
defer
engine
.
Close
()
defer
engine
.
Close
()
w
,
b
:=
newTestWorker
(
t
,
chainConfig
,
engine
)
w
,
b
:=
newTestWorker
(
t
,
chainConfig
,
engine
,
0
)
defer
w
.
close
()
defer
w
.
close
()
var
taskCh
=
make
(
chan
struct
{})
var
taskCh
=
make
(
chan
struct
{})
...
@@ -293,10 +307,10 @@ func testRegenerateMiningBlock(t *testing.T, chainConfig *params.ChainConfig, en
...
@@ -293,10 +307,10 @@ func testRegenerateMiningBlock(t *testing.T, chainConfig *params.ChainConfig, en
if
taskIndex
==
2
{
if
taskIndex
==
2
{
receiptLen
,
balance
:=
2
,
big
.
NewInt
(
2000
)
receiptLen
,
balance
:=
2
,
big
.
NewInt
(
2000
)
if
len
(
task
.
receipts
)
!=
receiptLen
{
if
len
(
task
.
receipts
)
!=
receiptLen
{
t
.
Errorf
(
"receipt number mismatch ha
s
%d, want %d"
,
len
(
task
.
receipts
),
receiptLen
)
t
.
Errorf
(
"receipt number mismatch
:
ha
ve
%d, want %d"
,
len
(
task
.
receipts
),
receiptLen
)
}
}
if
task
.
state
.
GetBalance
(
acc1
Addr
)
.
Cmp
(
balance
)
!=
0
{
if
task
.
state
.
GetBalance
(
testUser
Addr
ess
)
.
Cmp
(
balance
)
!=
0
{
t
.
Errorf
(
"account balance mismatch ha
s
%d, want %d"
,
task
.
state
.
GetBalance
(
acc1
Addr
),
balance
)
t
.
Errorf
(
"account balance mismatch
:
ha
ve
%d, want %d"
,
task
.
state
.
GetBalance
(
testUser
Addr
ess
),
balance
)
}
}
}
}
taskCh
<-
struct
{}{}
taskCh
<-
struct
{}{}
...
@@ -347,7 +361,7 @@ func TestAdjustIntervalClique(t *testing.T) {
...
@@ -347,7 +361,7 @@ func TestAdjustIntervalClique(t *testing.T) {
func
testAdjustInterval
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
func
testAdjustInterval
(
t
*
testing
.
T
,
chainConfig
*
params
.
ChainConfig
,
engine
consensus
.
Engine
)
{
defer
engine
.
Close
()
defer
engine
.
Close
()
w
,
_
:=
newTestWorker
(
t
,
chainConfig
,
engine
)
w
,
_
:=
newTestWorker
(
t
,
chainConfig
,
engine
,
0
)
defer
w
.
close
()
defer
w
.
close
()
w
.
skipSealHook
=
func
(
task
*
task
)
bool
{
w
.
skipSealHook
=
func
(
task
*
task
)
bool
{
...
@@ -387,10 +401,10 @@ func testAdjustInterval(t *testing.T, chainConfig *params.ChainConfig, engine co
...
@@ -387,10 +401,10 @@ func testAdjustInterval(t *testing.T, chainConfig *params.ChainConfig, engine co
// Check interval
// Check interval
if
minInterval
!=
wantMinInterval
{
if
minInterval
!=
wantMinInterval
{
t
.
Errorf
(
"resubmit min interval mismatch
want %s has %s"
,
wantM
inInterval
,
m
inInterval
)
t
.
Errorf
(
"resubmit min interval mismatch
: have %v, want %v "
,
m
inInterval
,
wantM
inInterval
)
}
}
if
recommitInterval
!=
wantRecommitInterval
{
if
recommitInterval
!=
wantRecommitInterval
{
t
.
Errorf
(
"resubmit interval mismatch
want %s has
%
s
"
,
wantR
ecommitInterval
,
r
ecommitInterval
)
t
.
Errorf
(
"resubmit interval mismatch
: have %v, want
%
v
"
,
r
ecommitInterval
,
wantR
ecommitInterval
)
}
}
result
=
append
(
result
,
float64
(
recommitInterval
.
Nanoseconds
()))
result
=
append
(
result
,
float64
(
recommitInterval
.
Nanoseconds
()))
index
+=
1
index
+=
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment