首页 文章

以太坊Go-ethereum等待交易

提问于
浏览
0

GETH VERSION

Geth的

版本:1.8.10稳定

Git Commit:eae63c511ceafab14b92e274c1b18bf1700e2d3d

架构:amd64

协议版本:[63 62]

网络ID:1

转到版本:go1.10.1

操作系统:linux

GOPATH = /家/ myuser的/去

GOROOT = / usr / lib目录/去-1.10

Node running under:

geth --testnet --rpc --rpcapi“eth,net,web3,personal,parity”--syncmode =“light”

Problem 1:

当我试图用--syncmode =“full”或--syncmode =“fast”运行Node时,CurrentBlock总是落后于HighestBlock,大约64块 . 所以Node在--syncmode =“light”下运行 .

My Goal is to find all pending transactions on my accounts.

Steps to reproduce

  • eth.getBlock('pending').transactions
["0x2e6d5273fa29e892313166b8de458793fb0728f13a9077ab2295c1dc2371529c", "0xcc2e659ea3f8b6f6c1b812d559198427b0b2adf0316213c903e08c277384a1c6", "0x6a194f095f3b9ee65fa2eb9765617edda8ea99c2f8ad3e09d03d61735acd3a34", "0x604f53727f6ad056d82f57ce07b4e28cfae16c098dca909bffeaa51fb3584843"]
  • Curl 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

It returns:

{ "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请求此事务

  • Now lets check 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}

I have to get the same result, But i got null!

Any idea? Or any suggestion of another way how to get incoming pending transactions?

1 回答

  • 0

    您始终可以使用getTransactionReceipt检查事务详细信息 . 你有没有可以尝试这个,如果你有时会得到null,可以回来吗?

    另外,关于您收到待处理交易的问题,请注意,这些待处理交易不适用于您的帐户或您的节点(如果您尚未发布任何交易) . 由于您已连接到以太坊的公共版本,因此您将获得这些交易,这些交易在某个矿工接收的某个晚些时间点并添加到分类帐中 . 对于答案,您可以编写一个后端,通过持续轮询来保存待处理的事务数据,从而达到您的目的 . 我希望我已经回答了你的问题 .

相关问题