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?
EOS.IO Stack Exchange is a question and answer site for users and developers of distributed applications built on top of the blockchain operating system, EOS.IO. It only takes a minute to sign up.
Sign up to join this communityAccording 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?
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);
}
}
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.