2

I am trying to develop little method to track status of my pending transactions by given address together with propagation info. But I am bit confused about pendingTransactionsStats behavior as it changes each time i check.

My code first check for pendingTransactions of my address then checks pendingTransactionsStats for hashes that retrieved from pendingTransactions.

var myAddr =  "0x2c5253b9055cfd3ac7a2d352934fb5c45f667367";
api.parity.pendingTransactions()
  .then((pendingTransactions)=>{

    // filter my transaction by my address
    let pendingQueue = _.filter(pendingTransactions, (a) =>  {return a.from.toLowerCase() == myAddr});   
    if(pendingQueue.length > 0) {

      // get stats of my pending transactions
      api.parity.pendingTransactionsStats().then((pendingTransactionsStats)=>{
        for (var i = 0, l = pendingQueue.length; i < l; i++) { 
          let pendingHash = pendingQueue[i].hash;
          console.log("pendingHash : " , pendingQueue[i].hash);
          console.log(pendingTransactionsStats[pendingHash]);
        }

      });
    } else {
      console.log("no pending transactions");
    }
  });

pendingTransactionsStats gives different propogation info each time i check. Sometimes doesnt even return anything. Is it expected behaviour? If yes, what should i understand from this. My aim is to be sure that my pending transaction is propagated to network. So i can be sure that reason of pending is not about network but only gasPrice.

My code outputs with few seconds inbetween :

pendingHash :  0x551e1af7c403c7fc847ecc2c4b8174e0853931f07fbc0eefd267a68fd87604e3
{ firstSeen: 3609956,
  propagatedTo: 
   { '0xd1da0fa61e0f1b69918ad330e59a12eddd1450256dd6837764c1d587b1adb5cf8ef661c043588f61ec0603e73fc641f5855ef486990ce13021d019e7a3c15de7': 1 } }

After few seconds no stats found:

pendingHash :  0x551e1af7c403c7fc847ecc2c4b8174e0853931f07fbc0eefd267a68fd87604e3
undefined

Then some more seconds and there two nodes :

{ firstSeen: 3609957,
  propagatedTo: 
   { '0x3b1dcc486de0b4b0cd2783b5fd770e183b0f063cd045b775e330aa8a3059ebff3d65131fa6f51761bef1152c54cfd9dd83b71aed38e9c1aaeb5660c8b73d5daa': 1,
     '0xf2170f44de933a592b6bac04f4926a81b7eae662abf888719e55a6556dd3dfbfa9ca36f314bc079d0ae2932fde27adee634363170d0316eb5a28e9baacca1868': 1 } }

One more question; what do those numbers indicate with peer Ids?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.