Skip to content

Commit

Permalink
const
Browse files Browse the repository at this point in the history
  • Loading branch information
shaspitz committed Aug 7, 2023
1 parent 9d111a8 commit 03daa2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions x/ccv/consumer/keeper/throttle_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import (
// This design is implemented below, and in relay.go under SendPackets() and OnAcknowledgementPacket().
//

// Retry delay period could be implemented as a param, but 1 hour is reasonable
const RETRY_DELAY_PERIOD = time.Hour

// PacketSendingPermitted returns whether the consumer is allowed to send packets
// from the pending packets queue.
func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool {
Expand All @@ -46,10 +49,8 @@ func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool {
// We are waiting on a reply from provider, block sending
return false
}
// Retry delay period could be implemented as a param, but 1 hour is reasonable
retryDelayPeriod := time.Hour
// If retry delay period has elapsed, we can send again
return ctx.BlockTime().After(record.SendTime.Add(retryDelayPeriod))
return ctx.BlockTime().After(record.SendTime.Add(RETRY_DELAY_PERIOD))
}

func (k Keeper) UpdateSlashRecordOnSend(ctx sdktypes.Context) {
Expand Down
3 changes: 2 additions & 1 deletion x/ccv/consumer/keeper/throttle_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/require"

testutil "github.com/cosmos/interchain-security/v3/testutil/keeper"
consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
)

Expand Down Expand Up @@ -41,7 +42,7 @@ func TestPacketSendingPermitted(t *testing.T) {
require.False(t, consumerKeeper.PacketSendingPermitted(ctx))

// Elapse retry delay period
ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * time.Hour))
ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * consumerkeeper.RETRY_DELAY_PERIOD))

// Now packet sending is permitted again
require.True(t, consumerKeeper.PacketSendingPermitted(ctx))
Expand Down

0 comments on commit 03daa2a

Please sign in to comment.