Skip to content

Commit

Permalink
CR Fix: Key and Data explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes committed Dec 31, 2023
1 parent 3f29fca commit 620343f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions x/timerstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ timerStore := timerStoreKeeper.NewTimerStoreBeginBlock(storeKey, timerPrefix).
WithCallbackByBlockTime(callbackFunction)
```

**Note on Timer Keys and Data:**

- **Subkey as Timer Identifier:** The `key` argument in the callback function refers to the timer's subkey. It's important to note that this subkey does not need to be unique across all timers. The `timerstore` module internally manages a unique primary key for each timer, ensuring distinct identification.
- **Data Attachment:** The `data` argument allows for attaching relevant information to the timer. This data is then accessible when the callback function is triggered, enabling context-specific actions based on the timer's purpose.

### Using the TimerStore

#### Overview of Timer Usage
Expand Down Expand Up @@ -93,6 +98,8 @@ AddTimerByBlockTime(ctx sdk.Context, timestamp uint64, key, data []byte)

```

When using `AddTimerByBlockHeight` and `AddTimerByBlockTime`, it's important to understand the `key` argument is the timer's subkey, which doesn't need to be unique. The unique primary key of each timer is internally managed by the timerstore. The `data` argument is for attaching additional information to the timer, available when the callback is triggered.

#### Timer Lifecycle

Once set, a timer remains active until triggered, after which it's automatically deleted. For recurring events, it's necessary to create a new timer each time.
Expand Down

0 comments on commit 620343f

Please sign in to comment.