doc.gno
1.15 Kb ยท 32 lines
1// Package timelock provides a library for scheduling, cancelling, and
2// executing time-locked operations in Gno. It ensures that
3// operations are only carried out after a specified delay and offers
4// mechanisms for managing and verifying the status of these operations.
5// This package leverages an AVL tree for efficient management of timestamps
6// and integrates role-based access control for administrative tasks.
7//
8// # Usage:
9//
10// import "gno.land/p/demo/timelock"
11// import "gno.land/p/demo/accesscontrol"
12//
13// Initialize timelock utility with an AVL tree and access control.
14// timestamps := avl.NewTree()
15// adminRole := accesscontrol.NewRole("admin", address("admin-address"))
16// timeLockUtil := timelock.NewTimeLockUtil(timestamps, adminRole, 30)
17//
18// Schedule an operation with a delay of 60 seconds.
19// id := seqid.ID()
20// timeLockUtil.Schedule(id, 60)
21//
22// Check if an operation is pending.
23// isPending := timeLockUtil.IsPending(id)
24//
25// Execute the operation when it is pending.
26// if timeLockUtil.IsPending(id) {
27// timeLockUtil.Execute(id)
28// }
29//
30// Update the minimum delay for future operations.
31// timeLockUtil.UpdateDelay(45)
32package timelock