1Hive / time-lock-app

The Time Lock app enables Aragon organizations to require users transfer or temporarily lock tokens before forwarding an intent.
GNU General Public License v3.0
16 stars 11 forks source link

Contract suggestions #77

Closed fabriziovigevani closed 4 years ago

fabriziovigevani commented 4 years ago

Includes suggestions from @bingen.

This is the approach suggested from @willjgriff where we shift all locks that haven't been unlocked yet after deletion.

Thought of an alternative approach where we perform a quickSort after deleting the items. PR with the alternative approach: https://github.com/1Hive/time-lock-app/pull/78

Regarding gas consumption:

This approach:

apporachfirst

Quick sort approach:

Screen Shot 2019-11-13 at 3 16 24 AM

When withdrawing all locks in quick sort approach, the gas consumption slightly increases since we still use deleteItem library function. Also, when withdrawing a partial amount of locks, the gas consumption is less since i would say that the resulting order of the array after deletion favours the amount of swaps done when sorting. Also, quick sort approach costs more gas when deploying

The gas prices difference are not that significant so i'm okay going with one approach or the other.

Maybe there is another alternative that haven't considered