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
d0bb90c6
Commit
d0bb90c6
authored
Jun 25, 2015
by
Felix Lange
Committed by
Jeffrey Wilcke
Jun 29, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: generate benchmark keys only once
parent
992dc74e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
bench_test.go
core/bench_test.go
+23
-9
No files found.
core/bench_test.go
View file @
d0bb90c6
...
...
@@ -72,16 +72,24 @@ func genValueTx(nbytes int) func(int, *BlockGen) {
}
}
var
(
ringKeys
=
make
([]
*
ecdsa
.
PrivateKey
,
1000
)
ringAddrs
=
make
([]
common
.
Address
,
len
(
ringKeys
))
)
func
init
()
{
ringKeys
[
0
]
=
benchRootKey
ringAddrs
[
0
]
=
benchRootAddr
for
i
:=
1
;
i
<
len
(
ringKeys
);
i
++
{
ringKeys
[
i
],
_
=
crypto
.
GenerateKey
()
ringAddrs
[
i
]
=
crypto
.
PubkeyToAddress
(
ringKeys
[
i
]
.
PublicKey
)
}
}
// genTxRing returns a block generator that sends ether in a ring
// among n accounts. This is creates n entries in the state database
// and fills the blocks with many small transactions.
func
genTxRing
(
naccounts
int
)
func
(
int
,
*
BlockGen
)
{
keys
:=
make
([]
*
ecdsa
.
PrivateKey
,
naccounts
)
keys
[
0
]
=
benchRootKey
for
i
:=
1
;
i
<
naccounts
;
i
++
{
keys
[
i
],
_
=
crypto
.
GenerateKey
()
}
from
:=
0
return
func
(
i
int
,
gen
*
BlockGen
)
{
gas
:=
CalcGasLimit
(
gen
.
PrevBlock
(
i
-
1
))
...
...
@@ -91,9 +99,15 @@ func genTxRing(naccounts int) func(int, *BlockGen) {
break
}
to
:=
(
from
+
1
)
%
naccounts
fromaddr
:=
crypto
.
PubkeyToAddress
(
keys
[
from
]
.
PublicKey
)
toaddr
:=
crypto
.
PubkeyToAddress
(
keys
[
to
]
.
PublicKey
)
tx
,
_
:=
types
.
NewTransaction
(
gen
.
TxNonce
(
fromaddr
),
toaddr
,
benchRootFunds
,
params
.
TxGas
,
nil
,
nil
)
.
SignECDSA
(
keys
[
from
])
tx
:=
types
.
NewTransaction
(
gen
.
TxNonce
(
ringAddrs
[
from
]),
ringAddrs
[
to
],
benchRootFunds
,
params
.
TxGas
,
nil
,
nil
,
)
tx
,
_
=
tx
.
SignECDSA
(
ringKeys
[
from
])
gen
.
AddTx
(
tx
)
from
=
to
}
...
...
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