4

According to the genesis block file. The maximum delay for a deferred transaction is 3888000.

"max_transaction_delay": 3888000,

Can we have a way around to deferred a transaction more than this delay?

6

You may modify your deferred transaction to call it recursively until remaining_delay is less than max_transaction_delay. The code snippet looks like this.

void deferred_txn(uint64_t delay,string sender_id,...){
        eosio::transaction txn{};
        uint64_t max_delay = 3888000; //max delay supported by EOS 

        if (delay <= max_delay){
        //perform your transaction here
        }
        else{
            uint64_t remaining_delay = delay - max_delay;
            sender_id = updateSenderId(sender_id); //sender id should be updated for every recursive call
            // transaction to update the delay
            txn.actions.emplace_back(
                eosio::permission_level(from, N(active)),
                N(contract_name),
                N(deferred_txn),
                std::make_tuple(remaining_delay,sender_id,...));
            txn.delay_sec = max_delay; // here we set the new delay which is maximum until remaining_delay is less the max_delay
            txn.send(eosio::string_to_name(sender_id.c_str()), from);
        } 
}
  • But updating the sender_id would have to handled carefully as at the time of cancelling we should have the latest sender_id, right? – Rajat Chaudhary Aug 14 '18 at 10:04
  • 1
    @RajatChaudhary You can frame the logic for generating sender_id based on counter which increments on every recursive call. This way, you can generate it on your end by approximating the counter based on start_time of transaction and max_delay. – Umesh Maheswari Aug 14 '18 at 10:24
3

You can add an intermediate deferred transaction that will have a counter and manage the extended time you want to defer to.

Say for example that you want to delay for

365*24*60*60*2 = 63072000 blocks

which is about a year, create an action that will save this number in your multi_index and call a deferred transaction for the max delay possible 3888000. Then once the delayed transaction is called, decrement the value by 3888000 and check if it is still more than 3888000. If it is, defer it again with the max of 3888000.

If it is less, call the final action which is the one you actually wanted and delay it by the remaining number.

This will have an effect of breaking past the limit, it is sort of a while loop that extends the delay.

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.