Can someone explain the difference between set_lock and extend_lock?

From my reading of the documentation on both, I figure that extend_lock should be called when we want to impose more locks on an already locked account, ie, if my pallet has already called set_lock on Alice, and she makes another call to the same pallet, rather than creating a new lock, I extend_lock.

Question : for a particular LockIdentifier does calling extend_lock add to the amount already locked and does set_lock reset the lock with a new amount with which it was called? Would that imply that extend_lock increases the number of locks on an account, whereas set_lock keeps the number of locks constant?

1 Answer 1

  • set_lock replaces any previous lock of the given identifier with the new lock. The previous amount which is locked under the given identifier is completely disregarded.
  • extend_lock does not replace any existing lock of the given identifier, but rather leaves the final amount locked as the maximum of the previous amount and the new amount.

Basically, if you do not want to reduce the amount that is locked with the given identifier, use extend_lock. If do want to allow the possibility of the amount locked with the given identifier to reduce, use set_lock.

In both cases, a new lock is created if there was no previous lock with the given identifier in place. Similarly no new locks are created if there was.

Your Answer

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

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