以太坊Go-ethereum等待交易

时间:2018-06-13 10:32:09

标签: ethereum go-ethereum

GETH VERSION

Geth的

版本:1.8.10-stable

Git Commit:eae63c511ceafab14b92e274c1b18bf1700e2d3d

架构:amd64

协议版本:[63 62]

网络ID:1

转到版本:go1.10.1

操作系统:linux

GOPATH = /家/ myuser的/去

GOROOT = / usr / lib中/去-1.10

节点在

下运行

geth --testnet --rpc --rpcapi" eth,net,web3,personal,parity" --syncmode ="光"

问题1:

当我尝试使用--syncmode =" full"或--syncmode =" fast",CurrentBlock总是落后于HighestBlock,大约64块。所以Node在--syncmode =" light"。

下运行

我的目标是在我的帐户中查找所有待处理的交易。

重现的步骤

  • eth.getBlock('pending').transactions

    ["0x2e6d5273fa29e892313166b8de458793fb0728f13a9077ab2295c1dc2371529c", "0xcc2e659ea3f8b6f6c1b812d559198427b0b2adf0316213c903e08c277384a1c6", "0x6a194f095f3b9ee65fa2eb9765617edda8ea99c2f8ad3e09d03d61735acd3a34", "0x604f53727f6ad056d82f57ce07b4e28cfae16c098dca909bffeaa51fb3584843"]
    
  • 卷曲eth_getTransactionByBlockHashAndIndex

        curl -X POST -H "Content-Type: application/json" --data'{"id":8,"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0xc0a9a6075081add64ac2f69b52f40de7b3d726281fc00a9ab23f90c892ae3346", "0x0"]}' http://localhost:8545
    

    返回:

    {"jsonrpc":"2.0",

     "id":8,
     "result":
         {"blockHash":"0xc0a9a6075081add64ac2f69b52f40de7b3d726281fc00a9ab23f90c892ae3346",
    
        "blockNumber":"0x344c3b",
        "from":"0x40e0b46c7a461c02ab6e70d5536e23a9d727f9f8",
        "gas":"0x927c0",
    
        "gasPrice":"0x218711a00",
        "hash":"0x2e6d5273fa29e892313166b8de458793fb0728f13a9077ab2295c1dc2371529c",
    
        "input":"0xfe6362ae000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000c3332353136303935323130370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c3037363832333538353537300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e516d54755334664370664531563444784c547079507074596874664845446f5734774c745159675837375a376378000000000000000000000000000000000000",
    
        "nonce":"0x161",
        "to":"0xabe486e0ad5319d8047d5ef83e8c1cb1dce0d8c5",
        "transactionIndex":"0x0","value":"0x0","v":"0x2a",
        "r":"0xd1c106a22480e173784267c4da3db1707e2efd7598d9c55c6e060842d8e42390",
        "s":"0x15786e1f7f4bd53e402d4911b0334b38973609415868687f171501b64770331e"}}
    

它完美无缺,现在让我们使用getTransactionByHash

来请求此事务
  • 现在让我们检查eth_getTransactionByHash:

       curl -X POST -H "Content-Type: application/json" --data '{"id":8,"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0x2e6d5273fa29e892313166b8de458793fb0728f13a9077ab2295c1dc2371529c"]}' http://localhost:8545
    

    返回

    {"jsonrpc":"2.0","id":8,"result":null}
    

我必须得到相同的结果,但我得到了空!

有什么想法吗?或者有任何其他方式的建议如何获得传入的待处理交易?

1 个答案:

答案 0 :(得分:0)

您始终可以使用getTransactionReceipt检查交易明细。 如果有时确实为空,可以请您尝试一下并返回吗?

另外,关于您遇到的有关未决交易的问题,请记住,这些未决交易不适用于您的帐户或您的节点(如果您尚未过帐)。由于您已连接到以太坊的公共版本,因此您将获得这些交易,这些交易是一些矿工在稍后获取的时间点,并被添加到分类账中。对于答案,您可以编写一个后端,该后端通过连续轮询来保存未决的交易数据,从而达到您的目的。希望我已经回答了您的问题。