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
056e9dd3
Commit
056e9dd3
authored
Jun 24, 2015
by
Bas van Kervel
Browse files
Options
Downloads
Patches
Plain Diff
added eth.pendingTransactions
parent
9226369b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
rpc/api/eth.go
+35
-5
35 additions, 5 deletions
rpc/api/eth.go
rpc/api/eth_args.go
+34
-0
34 additions, 0 deletions
rpc/api/eth_args.go
rpc/api/eth_js.go
+8
-0
8 additions, 0 deletions
rpc/api/eth_js.go
rpc/api/utils.go
+2
-1
2 additions, 1 deletion
rpc/api/utils.go
with
79 additions
and
6 deletions
rpc/api/eth.go
+
35
−
5
View file @
056e9dd3
...
...
@@ -6,9 +6,11 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/fatih/set.v0"
)
const
(
...
...
@@ -19,6 +21,7 @@ const (
// See https://github.com/ethereum/wiki/wiki/JSON-RPC
type
ethApi
struct
{
xeth
*
xeth
.
XEth
ethereum
*
eth
.
Ethereum
methods
map
[
string
]
ethhandler
codec
codec
.
ApiCoder
}
...
...
@@ -71,12 +74,13 @@ var (
"eth_hashrate"
:
(
*
ethApi
)
.
Hashrate
,
"eth_getWork"
:
(
*
ethApi
)
.
GetWork
,
"eth_submitWork"
:
(
*
ethApi
)
.
SubmitWork
,
"eth_pendingTransactions"
:
(
*
ethApi
)
.
PendingTransactions
,
}
)
// create new ethApi instance
func
NewEthApi
(
xeth
*
xeth
.
XEth
,
codec
codec
.
Codec
)
*
ethApi
{
return
&
ethApi
{
xeth
,
ethMapping
,
codec
.
New
(
nil
)}
func
NewEthApi
(
xeth
*
xeth
.
XEth
,
eth
*
eth
.
Ethereum
,
codec
codec
.
Codec
)
*
ethApi
{
return
&
ethApi
{
xeth
,
eth
,
ethMapping
,
codec
.
New
(
nil
)}
}
// collection with supported methods
...
...
@@ -548,3 +552,29 @@ func (self *ethApi) SubmitWork(req *shared.Request) (interface{}, error) {
}
return
self
.
xeth
.
RemoteMining
()
.
SubmitWork
(
args
.
Nonce
,
common
.
HexToHash
(
args
.
Digest
),
common
.
HexToHash
(
args
.
Header
)),
nil
}
func
(
self
*
ethApi
)
PendingTransactions
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
txs
:=
self
.
ethereum
.
TxPool
()
.
GetTransactions
()
// grab the accounts from the account manager. This will help with determening which
// transactions should be returned.
accounts
,
err
:=
self
.
ethereum
.
AccountManager
()
.
Accounts
()
if
err
!=
nil
{
return
nil
,
err
}
// Add the accouns to a new set
accountSet
:=
set
.
New
()
for
_
,
account
:=
range
accounts
{
accountSet
.
Add
(
account
.
Address
)
}
var
ltxs
[]
*
tx
for
_
,
tx
:=
range
txs
{
if
from
,
_
:=
tx
.
From
();
accountSet
.
Has
(
from
)
{
ltxs
=
append
(
ltxs
,
newTx
(
tx
))
}
}
return
ltxs
,
nil
}
This diff is collapsed.
Click to expand it.
rpc/api/eth_args.go
+
34
−
0
View file @
056e9dd3
...
...
@@ -5,8 +5,11 @@ import (
"fmt"
"math/big"
"strconv"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rpc/shared"
)
...
...
@@ -858,3 +861,34 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
}
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
(),
}
}
This diff is collapsed.
Click to expand it.
rpc/api/eth_js.go
+
8
−
0
View file @
056e9dd3
...
...
@@ -15,6 +15,14 @@ web3._extend({
inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
outputFormatter: web3._extend.formatters.formatOutputString
})
],
properties:
[
new web3._extend.Property({
name: 'pendingTransactions',
getter: 'eth_pendingTransactions',
outputFormatter: function(obj) { return obj; }
})
]
});
`
This diff is collapsed.
Click to expand it.
rpc/api/utils.go
+
2
−
1
View file @
056e9dd3
...
...
@@ -84,6 +84,7 @@ var (
"hashrate"
,
"getWork"
,
"submitWork"
,
"pendingTransactions"
,
},
"miner"
:
[]
string
{
"hashrate"
,
...
...
@@ -149,7 +150,7 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
case
shared
.
DbApiName
:
apis
[
i
]
=
NewDbApi
(
xeth
,
eth
,
codec
)
case
shared
.
EthApiName
:
apis
[
i
]
=
NewEthApi
(
xeth
,
codec
)
apis
[
i
]
=
NewEthApi
(
xeth
,
eth
,
codec
)
case
shared
.
MinerApiName
:
apis
[
i
]
=
NewMinerApi
(
eth
,
codec
)
case
shared
.
NetApiName
:
...
...
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