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
55a2f35a
Commit
55a2f35a
authored
Aug 20, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS Filter
parent
b97ea0e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
filter.go
ethchain/filter.go
+1
-3
js_pipe.go
ethpipe/js_pipe.go
+30
-5
bytes.go
ethutil/bytes.go
+22
-0
No files found.
ethchain/filter.go
View file @
55a2f35a
...
@@ -72,8 +72,6 @@ func NewFilterFromMap(object map[string]interface{}, eth EthManager) *Filter {
...
@@ -72,8 +72,6 @@ func NewFilterFromMap(object map[string]interface{}, eth EthManager) *Filter {
filter
.
altered
=
makeAltered
(
object
[
"altered"
])
filter
.
altered
=
makeAltered
(
object
[
"altered"
])
}
}
fmt
.
Println
(
"ALTERED"
,
filter
.
altered
)
return
filter
return
filter
}
}
...
@@ -123,7 +121,7 @@ func (self *Filter) SetTo(addr [][]byte) {
...
@@ -123,7 +121,7 @@ func (self *Filter) SetTo(addr [][]byte) {
}
}
func
(
self
*
Filter
)
AddTo
(
addr
[]
byte
)
{
func
(
self
*
Filter
)
AddTo
(
addr
[]
byte
)
{
self
.
from
=
append
(
self
.
to
,
addr
)
self
.
to
=
append
(
self
.
to
,
addr
)
}
}
func
(
self
*
Filter
)
SetMax
(
max
int
)
{
func
(
self
*
Filter
)
SetMax
(
max
int
)
{
...
...
ethpipe/js_pipe.go
View file @
55a2f35a
package
ethpipe
package
ethpipe
import
(
import
(
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"sync/atomic"
"sync/atomic"
...
@@ -119,6 +120,28 @@ func (self *JSPipe) EachStorage(addr string) string {
...
@@ -119,6 +120,28 @@ func (self *JSPipe) EachStorage(addr string) string {
return
string
(
valuesJson
)
return
string
(
valuesJson
)
}
}
func
(
self
*
JSPipe
)
ToAscii
(
str
string
)
string
{
padded
:=
ethutil
.
RightPadBytes
([]
byte
(
str
),
32
)
return
"0x"
+
ethutil
.
Bytes2Hex
(
padded
)
}
func
(
self
*
JSPipe
)
FromAscii
(
str
string
)
string
{
if
ethutil
.
IsHex
(
str
)
{
str
=
str
[
2
:
]
}
return
string
(
bytes
.
Trim
(
ethutil
.
Hex2Bytes
(
str
),
"
\x00
"
))
}
func
(
self
*
JSPipe
)
FromNumber
(
str
string
)
string
{
if
ethutil
.
IsHex
(
str
)
{
str
=
str
[
2
:
]
}
return
ethutil
.
BigD
(
ethutil
.
Hex2Bytes
(
str
))
.
String
()
}
func
(
self
*
JSPipe
)
Transact
(
key
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
*
JSReceipt
,
error
)
{
func
(
self
*
JSPipe
)
Transact
(
key
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
*
JSReceipt
,
error
)
{
var
hash
[]
byte
var
hash
[]
byte
var
contractCreation
bool
var
contractCreation
bool
...
@@ -200,8 +223,7 @@ func (self *JSPipe) Watch(object map[string]interface{}) *JSFilter {
...
@@ -200,8 +223,7 @@ func (self *JSPipe) Watch(object map[string]interface{}) *JSFilter {
func
(
self
*
JSPipe
)
Messages
(
object
map
[
string
]
interface
{})
string
{
func
(
self
*
JSPipe
)
Messages
(
object
map
[
string
]
interface
{})
string
{
filter
:=
self
.
Watch
(
object
)
filter
:=
self
.
Watch
(
object
)
filter
.
Uninstall
()
defer
filter
.
Uninstall
()
return
filter
.
Messages
()
return
filter
.
Messages
()
...
@@ -247,8 +269,8 @@ func (self *JSFilter) Messages() string {
...
@@ -247,8 +269,8 @@ func (self *JSFilter) Messages() string {
}
}
func
(
self
*
JSFilter
)
mainLoop
()
{
func
(
self
*
JSFilter
)
mainLoop
()
{
blockChan
:=
make
(
chan
ethreact
.
Event
,
1
)
blockChan
:=
make
(
chan
ethreact
.
Event
,
5
)
messageChan
:=
make
(
chan
ethreact
.
Event
,
1
)
messageChan
:=
make
(
chan
ethreact
.
Event
,
5
)
// Subscribe to events
// Subscribe to events
reactor
:=
self
.
eth
.
Reactor
()
reactor
:=
self
.
eth
.
Reactor
()
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
reactor
.
Subscribe
(
"newBlock"
,
blockChan
)
...
@@ -267,8 +289,11 @@ out:
...
@@ -267,8 +289,11 @@ out:
case
msg
:=
<-
messageChan
:
case
msg
:=
<-
messageChan
:
if
messages
,
ok
:=
msg
.
Resource
.
(
ethstate
.
Messages
);
ok
{
if
messages
,
ok
:=
msg
.
Resource
.
(
ethstate
.
Messages
);
ok
{
if
self
.
MessageCallback
!=
nil
{
if
self
.
MessageCallback
!=
nil
{
println
(
"messages!"
)
msgs
:=
self
.
FilterMessages
(
messages
)
msgs
:=
self
.
FilterMessages
(
messages
)
self
.
MessageCallback
(
msgs
)
if
len
(
msgs
)
>
0
{
self
.
MessageCallback
(
msgs
)
}
}
}
}
}
}
}
...
...
ethutil/bytes.go
View file @
55a2f35a
...
@@ -173,6 +173,28 @@ func LeftPadBytes(slice []byte, l int) []byte {
...
@@ -173,6 +173,28 @@ func LeftPadBytes(slice []byte, l int) []byte {
return
padded
return
padded
}
}
func
LeftPadString
(
str
string
,
l
int
)
string
{
if
l
<
len
(
str
)
{
return
str
}
zeros
:=
Bytes2Hex
(
make
([]
byte
,
(
l
-
len
(
str
))
/
2
))
return
zeros
+
str
}
func
RightPadString
(
str
string
,
l
int
)
string
{
if
l
<
len
(
str
)
{
return
str
}
zeros
:=
Bytes2Hex
(
make
([]
byte
,
(
l
-
len
(
str
))
/
2
))
return
str
+
zeros
}
func
Address
(
slice
[]
byte
)
(
addr
[]
byte
)
{
func
Address
(
slice
[]
byte
)
(
addr
[]
byte
)
{
if
len
(
slice
)
<
20
{
if
len
(
slice
)
<
20
{
addr
=
LeftPadBytes
(
slice
,
20
)
addr
=
LeftPadBytes
(
slice
,
20
)
...
...
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