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
05ac1209
Commit
05ac1209
authored
May 06, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: limit `pendingTransactions` to owned accounts.
parent
eb402925
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
33 deletions
+53
-33
admin.go
cmd/geth/admin.go
+53
-33
No files found.
cmd/geth/admin.go
View file @
05ac1209
...
@@ -16,6 +16,7 @@ import (
...
@@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
"github.com/ethereum/go-ethereum/xeth"
"github.com/robertkrimen/otto"
"github.com/robertkrimen/otto"
"gopkg.in/fatih/set.v0"
)
)
/*
/*
...
@@ -25,7 +26,7 @@ node admin bindings
...
@@ -25,7 +26,7 @@ node admin bindings
func
(
js
*
jsre
)
adminBindings
()
{
func
(
js
*
jsre
)
adminBindings
()
{
ethO
,
_
:=
js
.
re
.
Get
(
"eth"
)
ethO
,
_
:=
js
.
re
.
Get
(
"eth"
)
eth
:=
ethO
.
Object
()
eth
:=
ethO
.
Object
()
eth
.
Set
(
"
transactions"
,
js
.
t
ransactions
)
eth
.
Set
(
"
pendingTransactions"
,
js
.
pendingT
ransactions
)
eth
.
Set
(
"resend"
,
js
.
resend
)
eth
.
Set
(
"resend"
,
js
.
resend
)
js
.
re
.
Set
(
"admin"
,
struct
{}{})
js
.
re
.
Set
(
"admin"
,
struct
{}{})
...
@@ -80,43 +81,30 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
...
@@ -80,43 +81,30 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
return
nil
,
errors
.
New
(
"requires block number or block hash as argument"
)
return
nil
,
errors
.
New
(
"requires block number or block hash as argument"
)
}
}
type
tx
struct
{
func
(
js
*
jsre
)
pendingTransactions
(
call
otto
.
FunctionCall
)
otto
.
Value
{
tx
*
types
.
Transaction
txs
:=
js
.
ethereum
.
TxPool
()
.
GetTransactions
()
To
string
From
string
Nonce
string
Value
string
Data
string
GasLimit
string
GasPrice
string
}
func
newTx
(
t
*
types
.
Transaction
)
*
tx
{
// grab the accounts from the account manager. This will help with determening which
from
,
_
:=
t
.
From
()
// transactions should be returned.
var
to
string
accounts
,
err
:=
js
.
ethereum
.
AccountManager
()
.
Accounts
()
if
t
:=
t
.
To
();
t
!=
nil
{
if
err
!=
nil
{
to
=
t
.
Hex
()
fmt
.
Println
(
err
)
return
otto
.
UndefinedValue
()
}
}
return
&
tx
{
// Add the accouns to a new set
tx
:
t
,
accountSet
:=
set
.
New
()
To
:
to
,
for
_
,
account
:=
range
accounts
{
From
:
from
.
Hex
(),
accountSet
.
Add
(
common
.
BytesToAddress
(
account
.
Address
))
Value
:
t
.
Amount
.
String
(),
Nonce
:
strconv
.
Itoa
(
int
(
t
.
Nonce
())),
Data
:
"0x"
+
common
.
Bytes2Hex
(
t
.
Data
()),
GasLimit
:
t
.
GasLimit
.
String
(),
GasPrice
:
t
.
GasPrice
()
.
String
(),
}
}
}
func
(
js
*
jsre
)
transactions
(
call
otto
.
FunctionCall
)
otto
.
Value
{
txs
:=
js
.
ethereum
.
TxPool
()
.
GetTransactions
()
ltxs
:=
make
([]
*
tx
,
len
(
txs
))
//ltxs := make([]*tx, len(txs))
for
i
,
tx
:=
range
txs
{
var
ltxs
[]
*
tx
ltxs
[
i
]
=
newTx
(
tx
)
for
_
,
tx
:=
range
txs
{
// no need to check err
if
from
,
_
:=
tx
.
From
();
accountSet
.
Has
(
from
)
{
ltxs
=
append
(
ltxs
,
newTx
(
tx
))
}
}
}
return
js
.
re
.
ToVal
(
ltxs
)
return
js
.
re
.
ToVal
(
ltxs
)
...
@@ -504,3 +492,35 @@ func (js *jsre) dumpBlock(call otto.FunctionCall) otto.Value {
...
@@ -504,3 +492,35 @@ func (js *jsre) dumpBlock(call otto.FunctionCall) otto.Value {
return
js
.
re
.
ToVal
(
dump
)
return
js
.
re
.
ToVal
(
dump
)
}
}
// internal transaction type which will allow us to resend transactions using `eth.resend`
type
tx
struct
{
tx
*
types
.
Transaction
To
string
From
string
Nonce
string
Value
string
Data
string
GasLimit
string
GasPrice
string
}
func
newTx
(
t
*
types
.
Transaction
)
*
tx
{
from
,
_
:=
t
.
From
()
var
to
string
if
t
:=
t
.
To
();
t
!=
nil
{
to
=
t
.
Hex
()
}
return
&
tx
{
tx
:
t
,
To
:
to
,
From
:
from
.
Hex
(),
Value
:
t
.
Amount
.
String
(),
Nonce
:
strconv
.
Itoa
(
int
(
t
.
Nonce
())),
Data
:
"0x"
+
common
.
Bytes2Hex
(
t
.
Data
()),
GasLimit
:
t
.
GasLimit
.
String
(),
GasPrice
:
t
.
GasPrice
()
.
String
(),
}
}
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