Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
87b62f75
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
87b62f75
编写于
6月 10, 2015
作者:
B
Bas van Kervel
提交者:
Bas van Kervel
6月 11, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added txpool API
上级
c6c44338
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
91 addition
and
1 deletion
+91
-1
rpc/api/api.go
rpc/api/api.go
+2
-1
rpc/api/txpool.go
rpc/api/txpool.go
+67
-0
rpc/api/txpool_js.go
rpc/api/txpool_js.go
+18
-0
rpc/api/utils.go
rpc/api/utils.go
+4
-0
未找到文件。
rpc/api/api.go
浏览文件 @
87b62f75
...
...
@@ -13,6 +13,7 @@ const (
MergedApiName
=
"merged"
MinerApiName
=
"miner"
NetApiName
=
"net"
txPoolApiName
=
"txpool"
PersonalApiName
=
"personal"
Web3ApiName
=
"web3"
)
...
...
@@ -20,7 +21,7 @@ const (
var
(
// List with all API's which are offered over the IPC interface by default
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
87b62f75
...
...
@@ -31,6 +31,8 @@ func ParseApiString(apistr string, codec codec.Codec, xeth *xeth.XEth, eth *eth.
apis
[
i
]
=
NewMinerApi
(
eth
,
codec
)
case
NetApiName
:
apis
[
i
]
=
NewNetApi
(
xeth
,
eth
,
codec
)
case
txPoolApiName
:
apis
[
i
]
=
NewTxPoolApi
(
xeth
,
eth
,
codec
)
case
PersonalApiName
:
apis
[
i
]
=
NewPersonalApi
(
xeth
,
eth
,
codec
)
case
Web3ApiName
:
...
...
@@ -53,6 +55,8 @@ func Javascript(name string) string {
return
Miner_JS
case
NetApiName
:
return
Net_JS
case
txPoolApiName
:
return
TxPool_JS
case
PersonalApiName
:
return
Personal_JS
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录