1

I use the following script in geth console to print pending transaction number Uninterruptedly:

var timeInterval = 100;
setInterval(function(){
    var pending_txs = eth.getBlock('pending').transactions.length;
    console.log(pending_txs + " peding tx");
},timeInterval);

Every 100ms, the number updates in console like this:

86 peding tx
89 peding tx
89 peding tx
91 peding tx
93 peding tx
93 peding tx
93 peding tx
93 peding tx
94 peding tx
95 peding tx
96 peding tx
97 peding tx

However, when I use the following js script to print the hash value of all pending transactions

import { ethers } from "ethers";

const Provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");

const main = async () => {

  // Listen to the mempool on local node
  Provider.on("pending", (tx) =>
    {console.log(tx.hash)});

};

main();

At the beginning, the script will normally output the hash value of the transaction, but it will get stuck at some point in the future and no longer output any hash values. At the same time, the pending transaction in the local mempool is still being updated. Why does this happen? Any suggestions are appreciated.

0x78de6e0b0b79add0e7e42fa3c00d340709600f6a3105181b80cce6704ce6c43e
0x00ef5412caabc9269733298feaeadc2318c0e7a0029b3178a0d34e17cf3c0bbb
0x2ae81c9631be2743fba858f679c5916a8259196535399727c998d39f3e1a462c
0xd2173ff87f44eb92d6cea031aa4f90a30d7cc1d456d882532d5229e32cbd07b9
0x11e61ad5b10655bf6a80596c6734a1fd774cb6809e8ef89c375e339ce64d5927
0x0790d8548f2d63bcefc7e56560d917769a9fc0c0739fae92c3ae64db53e04b49
0x469f7d855e51a04dc50c68d74d7a458134444e068702c7b795da76e5eb2f362b
0x412281622cfb670368a97da36da354b8adf88be502e3afa89696c4031d73508a
0x9fe8c31ab931ddfc8fbb176b30e32b9dfba6523eec79e75690bfc15cfbd9f5b8
0x6acfe685e2b80df793aede60fea7489fba80493d8c103db6f42eef751c19d486
0xc70f1d02d6a7eb97031781ebb7fc1972eeae5488a93ca48e6da83cadf77f5bec
0x6b7ec243b6663c4c54b46ed4d282fe7547698f80ac65d6e6be1a9db59d2bd154
0x05b5a7e570d8ecb492aac2e0b061f576ed38243b74d5e73c6c3ea5d84ebebf7d
0x91020eaf09e3b31fef3aec087f55e4cf69eb7025e5b1fd87023c67cb41357653
0xbb67fcf54c6a719314b9b7fde72821852ecf201970a016afb648fbeaf0103b68
0xb1b336cc1c1fd840511b313b2150647e8c51bb2c5e58a6dc79af1bcd4d0495f7
0xb2fa63bc3c3c74361b8735c04ec6b0665ce953ee633b8aef90f58e6234933d7d
0x967a61fce1826a4cd9002e424c4b2780a2f94a3d5c2d9d69ab5baba5e1f450f6
0x50920db922dd0fd8b4ac0c31ab997c57538746abae3cf2721b6e890cc1c415a7
0x4819552baa941a8def83c9f03b9c7c17cccfe1191c54d3f7eacd7a9cee3f0f74
0xf2b8ef5905f2ea679da19a9bc78b7dc35ee018af46fb105613c330d3824a9999
0xa068e137a3ca7b2243ccd5de0df0876cae68aca4fa909041b5891385841f1b4b


0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.