Skip to content

Commit 4a4c67d

Browse files
implemented deleting of scheduled batch-config msg when handling same msg from shuttermint
1 parent a8f8282 commit 4a4c67d

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

rolling-shutter/keyper/database/keyper.sqlc.gen.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rolling-shutter/keyper/database/sql/queries/keyper.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ LIMIT 1;
121121
-- name: DeleteShutterMessage :exec
122122
DELETE FROM tendermint_outgoing_messages WHERE id=$1;
123123

124+
-- name: DeleteShutterMessageByDesc :exec
125+
DELETE FROM tendermint_outgoing_messages WHERE description=$1;
126+
124127
-- name: InsertEon :exec
125128
INSERT INTO eons (eon, height, activation_block_number, keyper_config_index)
126129
VALUES ($1, $2, $3, $4);

rolling-shutter/keyper/smobserver/smstate.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ func (st *ShuttermintState) handleBatchConfig(
274274
keypers = append(keypers, shdb.EncodeAddress(k))
275275
}
276276
keypermetrics.MetricsKeyperBatchConfigInfo.WithLabelValues(strconv.FormatUint(e.KeyperConfigIndex, 10), strings.Join(keypers, ",")).Set(1)
277-
return queries.InsertBatchConfig(
277+
if err := queries.InsertBatchConfig(
278278
ctx,
279279
database.InsertBatchConfigParams{
280280
KeyperConfigIndex: int32(e.KeyperConfigIndex),
@@ -284,7 +284,12 @@ func (st *ShuttermintState) handleBatchConfig(
284284
Started: e.Started,
285285
ActivationBlockNumber: int64(e.ActivationBlockNumber),
286286
},
287-
)
287+
); err != nil {
288+
return err
289+
}
290+
291+
return queries.DeleteShutterMessageByDesc(ctx, fmt.Sprintf("new batch config (activation-block-number=%d, config-index=%d)",
292+
e.ActivationBlockNumber, e.KeyperConfigIndex))
288293
}
289294

290295
func (st *ShuttermintState) handleBatchConfigStarted(

0 commit comments

Comments
 (0)