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
07cfb7b6
Commit
07cfb7b6
authored
Aug 14, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated filter so it accepts multiple from and to
parent
0d733aa0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
10 deletions
+38
-10
filter.go
ethchain/filter.go
+38
-10
No files found.
ethchain/filter.go
View file @
07cfb7b6
...
...
@@ -14,7 +14,7 @@ type Filter struct {
earliest
[]
byte
latest
[]
byte
skip
int
from
,
to
[]
byte
from
,
to
[]
[]
byte
max
int
}
...
...
@@ -53,14 +53,22 @@ func (self *Filter) SetLatestBlock(latest interface{}) {
}
}
func
(
self
*
Filter
)
SetFrom
(
addr
[]
byte
)
{
func
(
self
*
Filter
)
SetFrom
(
addr
[]
[]
byte
)
{
self
.
from
=
addr
}
func
(
self
*
Filter
)
SetTo
(
addr
[]
byte
)
{
func
(
self
*
Filter
)
AddFrom
(
addr
[]
byte
)
{
self
.
from
=
append
(
self
.
from
,
addr
)
}
func
(
self
*
Filter
)
SetTo
(
addr
[][]
byte
)
{
self
.
to
=
addr
}
func
(
self
*
Filter
)
AddTo
(
addr
[]
byte
)
{
self
.
from
=
append
(
self
.
to
,
addr
)
}
func
(
self
*
Filter
)
SetMax
(
max
int
)
{
self
.
max
=
max
}
...
...
@@ -101,13 +109,22 @@ func (self *Filter) Find() []*ethstate.Message {
break
}
includes
:=
func
(
addresses
[][]
byte
,
a
[]
byte
)
(
found
bool
)
{
for
_
,
addr
:=
range
addresses
{
if
bytes
.
Compare
(
addr
,
a
)
==
0
{
return
true
}
}
return
}
// Filter the messages for interesting stuff
for
_
,
message
:=
range
msgs
{
if
len
(
self
.
to
)
>
0
&&
bytes
.
Compare
(
message
.
To
,
self
.
to
)
!=
0
{
if
len
(
self
.
to
)
>
0
&&
!
includes
(
self
.
to
,
message
.
To
)
{
continue
}
if
len
(
self
.
from
)
>
0
&&
bytes
.
Compare
(
message
.
From
,
self
.
from
)
!=
0
{
if
len
(
self
.
from
)
>
0
&&
!
includes
(
self
.
from
,
message
.
From
)
{
continue
}
...
...
@@ -130,17 +147,28 @@ func (self *Filter) bloomFilter(block *Block) bool {
bloom
:=
NewBloomFilter
(
bin
)
var
fromIncluded
,
toIncluded
bool
if
len
(
self
.
from
)
>
0
{
if
!
bloom
.
Search
(
self
.
from
)
{
return
false
for
_
,
from
:=
range
self
.
from
{
if
bloom
.
Search
(
from
)
{
fromIncluded
=
true
break
}
}
}
else
{
fromIncluded
=
true
}
if
len
(
self
.
to
)
>
0
{
if
!
bloom
.
Search
(
self
.
to
)
{
return
false
for
_
,
to
:=
range
self
.
to
{
if
bloom
.
Search
(
to
)
{
toIncluded
=
true
break
}
}
}
else
{
toIncluded
=
true
}
return
true
return
fromIncluded
&&
toIncluded
}
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