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
87b62f75
Commit
87b62f75
authored
Jun 10, 2015
by
Bas van Kervel
Committed by
Bas van Kervel
Jun 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added txpool API
parent
c6c44338
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
91 additions
and
1 deletion
+91
-1
api.go
rpc/api/api.go
+2
-1
txpool.go
rpc/api/txpool.go
+67
-0
txpool_js.go
rpc/api/txpool_js.go
+18
-0
utils.go
rpc/api/utils.go
+4
-0
No files found.
rpc/api/api.go
View file @
87b62f75
...
@@ -13,6 +13,7 @@ const (
...
@@ -13,6 +13,7 @@ const (
MergedApiName
=
"merged"
MergedApiName
=
"merged"
MinerApiName
=
"miner"
MinerApiName
=
"miner"
NetApiName
=
"net"
NetApiName
=
"net"
txPoolApiName
=
"txpool"
PersonalApiName
=
"personal"
PersonalApiName
=
"personal"
Web3ApiName
=
"web3"
Web3ApiName
=
"web3"
)
)
...
@@ -20,7 +21,7 @@ const (
...
@@ -20,7 +21,7 @@ const (
var
(
var
(
// List with all API's which are offered over the IPC interface by default
// List with all API's which are offered over the IPC interface by default
DefaultIpcApis
=
strings
.
Join
([]
string
{
DefaultIpcApis
=
strings
.
Join
([]
string
{
AdminApiName
,
EthApiName
,
DebugApiName
,
MinerApiName
,
NetApiName
,
PersonalApiName
,
Web3ApiName
,
AdminApiName
,
EthApiName
,
DebugApiName
,
MinerApiName
,
NetApiName
,
txPoolApiName
,
PersonalApiName
,
Web3ApiName
,
},
","
)
},
","
)
)
)
...
...
rpc/api/txpool.go
0 → 100644
View file @
87b62f75
package
api
import
(
"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"
)
var
(
// mapping between methods and handlers
txpoolMapping
=
map
[
string
]
txpoolhandler
{
"txpool_status"
:
(
*
txPoolApi
)
.
Status
,
}
)
// net callback handler
type
txpoolhandler
func
(
*
txPoolApi
,
*
shared
.
Request
)
(
interface
{},
error
)
// txpool api provider
type
txPoolApi
struct
{
xeth
*
xeth
.
XEth
ethereum
*
eth
.
Ethereum
methods
map
[
string
]
txpoolhandler
codec
codec
.
ApiCoder
}
// create a new txpool api instance
func
NewTxPoolApi
(
xeth
*
xeth
.
XEth
,
eth
*
eth
.
Ethereum
,
coder
codec
.
Codec
)
*
txPoolApi
{
return
&
txPoolApi
{
xeth
:
xeth
,
ethereum
:
eth
,
methods
:
txpoolMapping
,
codec
:
coder
.
New
(
nil
),
}
}
// collection with supported methods
func
(
self
*
txPoolApi
)
Methods
()
[]
string
{
methods
:=
make
([]
string
,
len
(
self
.
methods
))
i
:=
0
for
k
:=
range
self
.
methods
{
methods
[
i
]
=
k
i
++
}
return
methods
}
// Execute given request
func
(
self
*
txPoolApi
)
Execute
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
if
callback
,
ok
:=
self
.
methods
[
req
.
Method
];
ok
{
return
callback
(
self
,
req
)
}
return
nil
,
shared
.
NewNotImplementedError
(
req
.
Method
)
}
func
(
self
*
txPoolApi
)
Name
()
string
{
return
txPoolApiName
}
func
(
self
*
txPoolApi
)
Status
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
return
map
[
string
]
int
{
"pending"
:
self
.
ethereum
.
TxPool
()
.
GetTransactions
()
.
Len
(),
"queued"
:
self
.
ethereum
.
TxPool
()
.
GetQueuedTransactions
()
.
Len
(),
},
nil
}
rpc/api/txpool_js.go
0 → 100644
View file @
87b62f75
package
api
const
TxPool_JS
=
`
web3._extend({
property: 'txpool',
methods:
[
],
properties:
[
new web3._extend.Property({
name: 'status',
getter: 'txpool_status',
outputFormatter: function(obj) { return obj; }
})
]
});
`
rpc/api/utils.go
View file @
87b62f75
...
@@ -31,6 +31,8 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
...
@@ -31,6 +31,8 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
apis
[
i
]
=
NewMinerApi
(
eth
,
codec
)
apis
[
i
]
=
NewMinerApi
(
eth
,
codec
)
case
NetApiName
:
case
NetApiName
:
apis
[
i
]
=
NewNetApi
(
xeth
,
eth
,
codec
)
apis
[
i
]
=
NewNetApi
(
xeth
,
eth
,
codec
)
case
txPoolApiName
:
apis
[
i
]
=
NewTxPoolApi
(
xeth
,
eth
,
codec
)
case
PersonalApiName
:
case
PersonalApiName
:
apis
[
i
]
=
NewPersonalApi
(
xeth
,
eth
,
codec
)
apis
[
i
]
=
NewPersonalApi
(
xeth
,
eth
,
codec
)
case
Web3ApiName
:
case
Web3ApiName
:
...
@@ -53,6 +55,8 @@ func Javascript(name string) string {
...
@@ -53,6 +55,8 @@ func Javascript(name string) string {
return
Miner_JS
return
Miner_JS
case
NetApiName
:
case
NetApiName
:
return
Net_JS
return
Net_JS
case
txPoolApiName
:
return
TxPool_JS
case
PersonalApiName
:
case
PersonalApiName
:
return
Personal_JS
return
Personal_JS
}
}
...
...
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