Geth管理API文档

admin
admin_addPeer:添加远程节点 admin_datadir:获取链库数据目录 admin_nodeInfo:获取节点信息 admin_peers:获取远程节点列表 admin_setSolc:设置solidity编译器路径 admin_startRPC:启动HTTP RPC服务 admin_startWS:启动WebSocket RPC服务 admin_stopRPC:停止HTTP RPC服务 admin_stopWS:停止WebSocket RPC服务
debug
debug_backtraceAt:设置回溯跟踪位置 debug_blockProfile:启用限时区块性能检测 debug_cpuProfile:启用限时CPU性能检测 debug_dumpBlock:导出指定区块 debug_gcStats:获取GC统计信息 debug_getBlockRlp:获取指定区块RPL编码数据 debug_goTrace:启用限时go运行时跟踪 debug_memStats:返回运行时内存统计 debug_seedHash:提取指定区块种子哈希 debug_setBlockProfileRate:设置区块性能检测速率 debug_setHead:设置本地链头区块 debug_stacks:返回go协程调用栈 debug_startCPUProfile:启用PCU性能检测 debug_startGoTrace:启用go运行时跟踪 debug_stopGoTrace:停止go运行时跟踪 debug_traceBlock:返回区块操作码调用栈 debug_traceBlockByNumber:返回指定序号区块调用栈 debug_traceBlockByHash:返回指定哈希区块调用栈 debug_traceBlockFromFile:返回指定区块文件调用栈 debug_traceTransaction:交易模拟跟踪 debug_verbosity:设置日志输出级别 debug_vmodule:设置日志可视模式 debug_writeBlockProfile:保存区块性能检测数据 debug_writeMemProfile:保存内存性能检测数据
miner
miner_setExtra:设置区块挖矿额外数据 miner_setGasPrice:设置gas价格下限 miner_start:启动CPU挖矿 miner_stop:停止CPU挖矿 miner_getHashrate:获取哈希生成速率 miner_setEtherBase:设置挖矿收益账户
personal
personal_importRawKey:导入私钥 personal_listAccounts:获取账户清单 personal_lockAccount:锁定账户 personal_newAccount:创建新账户 personal_unlockAccount:解锁账户 personal_sendTransaction:发送交易 personal_sign:消息签名 personal_ecRecover:提取签名中的发起账户
txpool
txpool_content:获取池内交易详情 txpool_inspect:获取池内交易概况 txpool_status:获取交易状态

admin_peers

peers属性可用来查询当前geth节点已连接的远程节点的相关信息,包括ÐΞVp2p协议信息 以及运行中的应用协议信息,例如eth、les、shh、bzz等。

调用方法

Go:

admin.Peers() ([]*p2p.PeerInfo, error)

Geth控制台:

admin.peers

JSON RPC:

{"method": "admin_peers"}

示例代码

下面的示例展示了在Geth控制台中如何使用peers属性获取当前geth节点所 连接的远程节点旳网络信息:

> admin.peers
[{
    caps: ["eth/61", "eth/62", "eth/63"],
    id: "08a6b39263470c78d3e4f58e3c997cd2e7af623afce64656cfc56480babcea7a9138f3d09d7b9879344c2d2e457679e3655d4b56eaff5fd4fd7f147bdb045124",
    name: "Geth/v1.5.0-unstable/linux/go1.5.1",
    network: {
      localAddress: "192.168.0.104:51068",
      remoteAddress: "71.62.31.72:30303"
    },
    protocols: {
      eth: {
        difficulty: 17334052235346465000,
        head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
        version: 63
      }
    }
}, /* ... */ {
    caps: ["eth/61", "eth/62", "eth/63"],
    id: "fcad9f6d3faf89a0908a11ddae9d4be3a1039108263b06c96171eb3b0f3ba85a7095a03bb65198c35a04829032d198759edfca9b63a8b69dc47a205d94fce7cc",
    name: "Geth/v1.3.5-506c9277/linux/go1.4.2",
    network: {
      localAddress: "192.168.0.104:55968",
      remoteAddress: "121.196.232.205:30303"
    },
    protocols: {
      eth: {
        difficulty: 17335165914080772000,
        head: "5794b768dae6c6ee5366e6ca7662bdff2882576e09609bf778633e470e0e7852",
        version: 63
      }
    }
}]