2018-08-24 23:18:41 +00:00
|
|
|
package paychan
|
|
|
|
|
|
|
|
import ()
|
|
|
|
|
2018-08-27 21:58:58 +00:00
|
|
|
func EndBlocker(ctx sdk.Context, k Keeper) sdk.Tags {
|
2018-08-24 23:18:41 +00:00
|
|
|
|
2018-08-27 21:58:58 +00:00
|
|
|
// Iterate through submittedUpdatesQueue
|
|
|
|
// TODO optimise so it doesn't pull every update from DB every block
|
|
|
|
var sUpdate SubmittedUpdate
|
|
|
|
q := k.getSubmittedUpdatesQueue(ctx)
|
|
|
|
for _, id := range q {
|
|
|
|
// close the channel if the update has reached its execution time.
|
|
|
|
// Using >= in case some are somehow missed.
|
|
|
|
sUpdate = k.getSubmittedUpdate(ctx, id)
|
|
|
|
if ctx.BlockHeight() >= sUpdate.ExecutionTime {
|
|
|
|
k.closeChannel(ctx, sUpdate.Update)
|
|
|
|
}
|
|
|
|
}
|
2018-08-24 23:18:41 +00:00
|
|
|
|
|
|
|
tags := sdk.NewTags()
|
|
|
|
return tags
|
2018-08-27 21:58:58 +00:00
|
|
|
}
|