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
30f057aa
Commit
30f057aa
authored
Oct 12, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
eth/filters: added benchmark
parent
cefe5c80
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
core/chain_makers.go
+4
-0
4 additions, 0 deletions
core/chain_makers.go
eth/filters/filter.go
+1
-7
1 addition, 7 deletions
eth/filters/filter.go
eth/filters/filter_test.go
+95
-0
95 additions, 0 deletions
eth/filters/filter_test.go
with
100 additions
and
7 deletions
core/chain_makers.go
+
4
−
0
View file @
30f057aa
...
...
@@ -105,6 +105,10 @@ func (b *BlockGen) AddTx(tx *types.Transaction) {
b
.
receipts
=
append
(
b
.
receipts
,
receipt
)
}
func
(
b
*
BlockGen
)
AddReceipt
(
receipt
*
types
.
Receipt
)
{
b
.
receipts
=
append
(
b
.
receipts
,
receipt
)
}
// TxNonce returns the next valid transaction nonce for the
// account at addr. It panics if the account does not exist.
func
(
b
*
BlockGen
)
TxNonce
(
addr
common
.
Address
)
uint64
{
...
...
This diff is collapsed.
Click to expand it.
eth/filters/filter.go
+
1
−
7
View file @
30f057aa
...
...
@@ -17,8 +17,6 @@
package
filters
import
(
"math"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -107,8 +105,6 @@ done:
break
done
case
block
.
NumberU64
()
<
earliestBlockNo
:
break
done
case
self
.
max
<=
len
(
logs
)
:
break
done
}
// Use bloom filtering to see if this block is interesting given the
...
...
@@ -128,9 +124,7 @@ done:
block
=
core
.
GetBlock
(
self
.
db
,
block
.
ParentHash
())
}
skip
:=
int
(
math
.
Min
(
float64
(
len
(
logs
)),
float64
(
self
.
skip
)))
return
logs
[
skip
:
]
return
logs
}
func
includes
(
addresses
[]
common
.
Address
,
a
common
.
Address
)
bool
{
...
...
This diff is collapsed.
Click to expand it.
eth/filters/filter_test.go
0 → 100644
+
95
−
0
View file @
30f057aa
package
filters
import
(
"math/big"
"os"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
)
func
makeReceipt
(
addr
common
.
Address
)
*
types
.
Receipt
{
receipt
:=
types
.
NewReceipt
(
nil
,
new
(
big
.
Int
))
receipt
.
SetLogs
(
vm
.
Logs
{
&
vm
.
Log
{
Address
:
addr
},
})
receipt
.
Bloom
=
types
.
CreateBloom
(
types
.
Receipts
{
receipt
})
return
receipt
}
func
BenchmarkMipmaps
(
b
*
testing
.
B
)
{
const
dbname
=
"/tmp/mipmap"
var
(
db
,
_
=
ethdb
.
NewLDBDatabase
(
dbname
,
16
)
key1
,
_
=
crypto
.
HexToECDSA
(
"b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291"
)
addr1
=
crypto
.
PubkeyToAddress
(
key1
.
PublicKey
)
addr2
=
common
.
BytesToAddress
([]
byte
(
"jeff"
))
addr3
=
common
.
BytesToAddress
([]
byte
(
"ethereum"
))
addr4
=
common
.
BytesToAddress
([]
byte
(
"random addresses please"
))
)
defer
func
()
{
db
.
Close
()
os
.
Remove
(
dbname
)
}()
genesis
:=
core
.
WriteGenesisBlockForTesting
(
db
,
core
.
GenesisAccount
{
addr1
,
big
.
NewInt
(
1000000
)})
chain
:=
core
.
GenerateChain
(
genesis
,
db
,
100000
,
func
(
i
int
,
gen
*
core
.
BlockGen
)
{
var
receipts
types
.
Receipts
switch
i
{
case
2403
:
receipt
:=
makeReceipt
(
addr1
)
receipts
=
types
.
Receipts
{
receipt
}
gen
.
AddReceipt
(
receipt
)
case
10340
:
receipt
:=
makeReceipt
(
addr2
)
receipts
=
types
.
Receipts
{
receipt
}
gen
.
AddReceipt
(
receipt
)
case
34
:
receipt
:=
makeReceipt
(
addr3
)
receipts
=
types
.
Receipts
{
receipt
}
gen
.
AddReceipt
(
receipt
)
case
99999
:
receipt
:=
makeReceipt
(
addr4
)
receipts
=
types
.
Receipts
{
receipt
}
gen
.
AddReceipt
(
receipt
)
}
// store the receipts
err
:=
core
.
PutReceipts
(
db
,
receipts
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
})
for
_
,
block
:=
range
chain
{
core
.
WriteBlock
(
db
,
block
)
if
err
:=
core
.
WriteCanonicalHash
(
db
,
block
.
Hash
(),
block
.
NumberU64
());
err
!=
nil
{
b
.
Fatalf
(
"failed to insert block number: %v"
,
err
)
}
if
err
:=
core
.
WriteHeadBlockHash
(
db
,
block
.
Hash
());
err
!=
nil
{
b
.
Fatalf
(
"failed to insert block number: %v"
,
err
)
}
if
err
:=
core
.
PutBlockReceipts
(
db
,
block
,
block
.
Receipts
());
err
!=
nil
{
b
.
Fatal
(
"error writing block receipts:"
,
err
)
}
}
b
.
ResetTimer
()
filter
:=
New
(
db
)
filter
.
SetAddress
([]
common
.
Address
{
addr1
,
addr2
,
addr3
,
addr4
})
filter
.
SetEarliestBlock
(
0
)
filter
.
SetLatestBlock
(
-
1
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
logs
:=
filter
.
Find
()
if
len
(
logs
)
!=
4
{
b
.
Fatal
(
"expected 4 log, got"
,
len
(
logs
))
}
}
}
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