0

I have a method in my contract that is supposed to reset a list of items.

bytes32[10] public items; 

function reset() {
    items = [0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0];
} 

In my app, I reset items before retrieving them using web3:

contract.methods.reset().send({from: my_wallet})
.on('confirmation', confirmation => {
    if (confirmation) return;
    for (var i = 0 ; i < 10 ; ++i) {
        (function(i){
            contract.methods.items(i).call()
            .then( res => console.log(i + " " + res) );
        }(i));
    }
})

This usually works and I get resetted values. However, 10% of the time I get old values even though my reset transaction has been just confirmed! Furthermore if I check using Parity UI, the values are indeed resetted!

I'm using web3 1.0.0-beta.18 on a private chain with a single node, so there's no propagation time either.

1

Web3.js does nothing here than resting those requests to the node, the confirmation is fired if a receipt is available. I would suggest upgrading to beta.21 and see if that fixes item, as we made a slight iteration, or waiting for confirmation #2

2
  • Thanks Fabian. I know from experience that confirmation is not fired at the same time as receipt. Also waiting for confirmation #2 means waiting 3 blocks on a single node, makes no sense tbh.
    – d9ngle
    Sep 25 '17 at 12:07
  • Somebody from the go team has to answer on that, if its the case its not good i agree. Sep 26 '17 at 13:42

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.