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:获取交易状态

txpool_content

txpoolcontent属性可以用来当前在池中的待定和排队交易清单,值为一个 包含两个字段的对象:pending和queued,每个字段都是一个关联数组。

请注意,可能会有多个交易与同一个账户和nonce关联,当用户使用不同的 gas设置多次广播交易时可能会发生此现象。

调用方法

Go:

txpool.Content() (map[string]map[string]map[string][]*RPCTransaction)

Geth控制台:

txpool.content

JSON RPC:

{"method": "txpool_content"}

示例代码

下面的示例在Geth控制台中使用content属性获取交易池中的待定和排队交易:

> txpool.content
{
  pending: {
    0x0216d5032f356960cd3749c31ab34eeff21b3395: {
      806: [{
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x0216d5032f356960cd3749c31ab34eeff21b3395",
        gas: "0x5208",
        gasPrice: "0xba43b7400",
        hash: "0xaf953a2d01f55cfe080c0c94150a60105e8ac3d51153058a1f03dd239dd08586",
        input: "0x",
        nonce: "0x326",
        to: "0x7f69a91a3cf4be60020fb58b893b7cbb65376db8",
        transactionIndex: null,
        value: "0x19a99f0cf456000"
      }]
    },
    0x24d407e5a0b506e1cb2fae163100b5de01f5193c: {
      34: [{
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x24d407e5a0b506e1cb2fae163100b5de01f5193c",
        gas: "0x44c72",
        gasPrice: "0x4a817c800",
        hash: "0xb5b8b853af32226755a65ba0602f7ed0e8be2211516153b75e9ed640a7d359fe",
        input: "0xb61d27f600000000000000000000000024d407e5a0b506e1cb2fae163100b5de01f5193c00000000000000000000000000000000000000000000000053444835ec580000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        nonce: "0x22",
        to: "0x7320785200f74861b69c49e4ab32399a71b34f1a",
        transactionIndex: null,
        value: "0x0"
      }]
    }
  },
  queued: {
    0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c: {
      3: [{
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c",
        gas: "0x15f90",
        gasPrice: "0x4a817c800",
        hash: "0x57b30c59fc39a50e1cba90e3099286dfa5aaf60294a629240b5bbec6e2e66576",
        input: "0x",
        nonce: "0x3",
        to: "0x346fb27de7e7370008f5da379f74dd49f5f2f80f",
        transactionIndex: null,
        value: "0x1f161421c8e0000"
      }]
    },
    0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a: {
      2: [{
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
        gas: "0x15f90",
        gasPrice: "0xba43b7400",
        hash: "0x3a3c0698552eec2455ed3190eac3996feccc806970a4a056106deaf6ceb1e5e3",
        input: "0x",
        nonce: "0x2",
        to: "0x24a461f25ee6a318bdef7f33de634a67bb67ac9d",
        transactionIndex: null,
        value: "0xebec21ee1da40000"
      }],
      6: [{
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
        gas: "0x15f90",
        gasPrice: "0x4a817c800",
        hash: "0xbbcd1e45eae3b859203a04be7d6e1d7b03b222ec1d66dfcc8011dd39794b147e",
        input: "0x",
        nonce: "0x6",
        to: "0x6368f3f8c2b42435d6c136757382e4a59436a681",
        transactionIndex: null,
        value: "0xf9a951af55470000"
      }, {
        blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        blockNumber: null,
        from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a",
        gas: "0x15f90",
        gasPrice: "0x4a817c800",
        hash: "0x60803251d43f072904dc3a2d6a084701cd35b4985790baaf8a8f76696041b272",
        input: "0x",
        nonce: "0x6",
        to: "0x8db7b4e0ecb095fbd01dffa62010801296a9ac78",
        transactionIndex: null,
        value: "0xebe866f5f0a06000"
      }],
    }
  }
}