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
1d519854
Commit
1d519854
authored
Feb 05, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate known transactions to new peers on connect
parent
292f7ada
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
22 deletions
+30
-22
coin.html
cmd/mist/assets/examples/coin.html
+4
-4
filter.go
core/filter.go
+9
-14
protocol.go
eth/protocol.go
+12
-0
args.go
rpc/args.go
+3
-3
message.go
rpc/message.go
+1
-1
packages.go
rpc/packages.go
+1
-0
No files found.
cmd/mist/assets/examples/coin.html
View file @
1d519854
...
@@ -57,8 +57,8 @@
...
@@ -57,8 +57,8 @@
"name"
:
"Changed"
,
"name"
:
"Changed"
,
"type"
:
"event"
,
"type"
:
"event"
,
"inputs"
:
[
"inputs"
:
[
{
"name"
:
"to"
,
"type"
:
"address"
,
"indexed"
:
fals
e
},
{
"name"
:
"to"
,
"type"
:
"address"
,
"indexed"
:
tru
e
},
{
"name"
:
"amount"
,
"type"
:
"uint256"
,
"indexed"
:
tru
e
},
{
"name"
:
"amount"
,
"type"
:
"uint256"
,
"indexed"
:
fals
e
},
],
],
}];
}];
...
@@ -74,12 +74,12 @@
...
@@ -74,12 +74,12 @@
}
}
var
contract
=
web3
.
eth
.
contract
(
address
,
desc
);
var
contract
=
web3
.
eth
.
contract
(
address
,
desc
);
contract
.
Changed
({
to
:
"0xaa
bb
"
}).
changed
(
function
(
e
)
{
contract
.
Changed
({
to
:
"0xaa"
}).
changed
(
function
(
e
)
{
console
.
log
(
"e: "
+
JSON
.
stringify
(
e
));
console
.
log
(
"e: "
+
JSON
.
stringify
(
e
));
});
});
contract
.
transact
({
gas
:
"10000"
,
gasprice
:
eth
.
gasPrice
}).
send
(
"0xaa"
,
10000
);
contract
.
transact
({
gas
:
"10000"
,
gasprice
:
eth
.
gasPrice
}).
send
(
"0xaa"
,
10000
);
function
reflesh
()
{
function
reflesh
()
{
document
.
querySelector
(
"#balance"
).
innerHTML
=
contract
.
call
().
balance
(
eth
.
coinbase
);
document
.
querySelector
(
"#balance"
).
innerHTML
=
contract
.
balance
(
eth
.
coinbase
);
var
table
=
document
.
querySelector
(
"#table"
);
var
table
=
document
.
querySelector
(
"#table"
);
table
.
innerHTML
=
""
;
// clear
table
.
innerHTML
=
""
;
// clear
...
...
core/filter.go
View file @
1d519854
...
@@ -2,7 +2,6 @@ package core
...
@@ -2,7 +2,6 @@ package core
import
(
import
(
"bytes"
"bytes"
"fmt"
"math"
"math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
...
@@ -129,37 +128,33 @@ func (self *Filter) Find() state.Logs {
...
@@ -129,37 +128,33 @@ func (self *Filter) Find() state.Logs {
return
logs
[
skip
:
]
return
logs
[
skip
:
]
}
}
func
includes
(
addresses
[][]
byte
,
a
[]
byte
)
(
found
bool
)
{
func
includes
(
addresses
[][]
byte
,
a
[]
byte
)
bool
{
for
_
,
addr
:=
range
addresses
{
for
_
,
addr
:=
range
addresses
{
fmt
.
Println
(
"INCLUDES"
,
addr
,
a
)
if
!
bytes
.
Equal
(
addr
,
a
)
{
if
bytes
.
Compare
(
addr
,
a
)
==
0
{
return
false
return
true
}
}
}
}
return
return
true
}
}
func
(
self
*
Filter
)
FilterLogs
(
logs
state
.
Logs
)
state
.
Logs
{
func
(
self
*
Filter
)
FilterLogs
(
logs
state
.
Logs
)
state
.
Logs
{
fmt
.
Println
(
"FILTER LOGS"
,
self
.
topics
)
var
ret
state
.
Logs
var
ret
state
.
Logs
// Filter the logs for interesting stuff
// Filter the logs for interesting stuff
Logs
:
for
_
,
log
:=
range
logs
{
for
_
,
log
:=
range
logs
{
fmt
.
Println
(
log
)
if
len
(
self
.
address
)
>
0
&&
!
bytes
.
Equal
(
self
.
address
,
log
.
Address
())
{
if
len
(
self
.
address
)
>
0
&&
!
bytes
.
Equal
(
self
.
address
,
log
.
Address
())
{
continue
continue
}
}
for
_
,
topic
:=
range
self
.
topics
{
max
:=
int
(
math
.
Min
(
float64
(
len
(
self
.
topics
)),
float64
(
len
(
log
.
Topics
()))))
fmt
.
Println
(
"TOPIC:"
,
topic
)
for
i
:=
0
;
i
<
max
;
i
++
{
if
!
includes
(
log
.
Topics
(),
topic
)
{
if
!
bytes
.
Equal
(
log
.
Topics
()[
i
],
self
.
topics
[
i
]
)
{
continue
continue
Logs
}
}
}
}
fmt
.
Println
(
"APPENDED"
)
ret
=
append
(
ret
,
log
)
ret
=
append
(
ret
,
log
)
}
}
...
...
eth/protocol.go
View file @
1d519854
...
@@ -46,6 +46,7 @@ type ethProtocol struct {
...
@@ -46,6 +46,7 @@ type ethProtocol struct {
// used as an argument to EthProtocol
// used as an argument to EthProtocol
type
txPool
interface
{
type
txPool
interface
{
AddTransactions
([]
*
types
.
Transaction
)
AddTransactions
([]
*
types
.
Transaction
)
GetTransactions
()
types
.
Transactions
}
}
type
chainManager
interface
{
type
chainManager
interface
{
...
@@ -101,6 +102,7 @@ func runEthProtocol(txPool txPool, chainManager chainManager, blockPool blockPoo
...
@@ -101,6 +102,7 @@ func runEthProtocol(txPool txPool, chainManager chainManager, blockPool blockPoo
}
}
err
=
self
.
handleStatus
()
err
=
self
.
handleStatus
()
if
err
==
nil
{
if
err
==
nil
{
self
.
propagateTxs
()
for
{
for
{
err
=
self
.
handle
()
err
=
self
.
handle
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -324,3 +326,13 @@ func (self *ethProtocol) protoErrorDisconnect(code int, format string, params ..
...
@@ -324,3 +326,13 @@ func (self *ethProtocol) protoErrorDisconnect(code int, format string, params ..
}
}
}
}
func
(
self
*
ethProtocol
)
propagateTxs
()
{
transactions
:=
self
.
txPool
.
GetTransactions
()
iface
:=
make
([]
interface
{},
len
(
transactions
))
for
i
,
transaction
:=
range
transactions
{
iface
[
i
]
=
transaction
}
self
.
rw
.
WriteMsg
(
p2p
.
NewMsg
(
TxMsg
,
iface
...
))
}
rpc/args.go
View file @
1d519854
...
@@ -214,7 +214,7 @@ type FilterOptions struct {
...
@@ -214,7 +214,7 @@ type FilterOptions struct {
Earliest
int64
Earliest
int64
Latest
int64
Latest
int64
Address
string
Address
string
Topic
s
[]
string
Topic
[]
string
Skip
int
Skip
int
Max
int
Max
int
}
}
...
@@ -224,8 +224,8 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions {
...
@@ -224,8 +224,8 @@ func toFilterOptions(options *FilterOptions) core.FilterOptions {
opts
.
Earliest
=
options
.
Earliest
opts
.
Earliest
=
options
.
Earliest
opts
.
Latest
=
options
.
Latest
opts
.
Latest
=
options
.
Latest
opts
.
Address
=
fromHex
(
options
.
Address
)
opts
.
Address
=
fromHex
(
options
.
Address
)
opts
.
Topics
=
make
([][]
byte
,
len
(
options
.
Topic
s
))
opts
.
Topics
=
make
([][]
byte
,
len
(
options
.
Topic
))
for
i
,
topic
:=
range
options
.
Topic
s
{
for
i
,
topic
:=
range
options
.
Topic
{
opts
.
Topics
[
i
]
=
fromHex
(
topic
)
opts
.
Topics
[
i
]
=
fromHex
(
topic
)
}
}
...
...
rpc/message.go
View file @
1d519854
...
@@ -206,7 +206,7 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
...
@@ -206,7 +206,7 @@ func (req *RpcRequest) ToFilterArgs() (*FilterOptions, error) {
if
len
(
req
.
Params
)
<
1
{
if
len
(
req
.
Params
)
<
1
{
return
nil
,
NewErrorResponse
(
ErrorArguments
)
return
nil
,
NewErrorResponse
(
ErrorArguments
)
}
}
fmt
.
Println
(
"
filter params"
,
req
.
Params
)
fmt
.
Println
(
"
FILTER PARAMS"
,
string
(
req
.
Params
[
0
])
)
args
:=
new
(
FilterOptions
)
args
:=
new
(
FilterOptions
)
r
:=
bytes
.
NewReader
(
req
.
Params
[
0
])
r
:=
bytes
.
NewReader
(
req
.
Params
[
0
])
...
...
rpc/packages.go
View file @
1d519854
...
@@ -70,6 +70,7 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
...
@@ -70,6 +70,7 @@ func NewEthereumApi(eth *xeth.XEth) *EthereumApi {
func
(
self
*
EthereumApi
)
NewFilter
(
args
*
FilterOptions
,
reply
*
interface
{})
error
{
func
(
self
*
EthereumApi
)
NewFilter
(
args
*
FilterOptions
,
reply
*
interface
{})
error
{
var
id
int
var
id
int
filter
:=
core
.
NewFilter
(
self
.
xeth
.
Backend
())
filter
:=
core
.
NewFilter
(
self
.
xeth
.
Backend
())
filter
.
SetOptions
(
toFilterOptions
(
args
))
filter
.
LogsCallback
=
func
(
logs
state
.
Logs
)
{
filter
.
LogsCallback
=
func
(
logs
state
.
Logs
)
{
self
.
logMut
.
Lock
()
self
.
logMut
.
Lock
()
defer
self
.
logMut
.
Unlock
()
defer
self
.
logMut
.
Unlock
()
...
...
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