From 25fc9840da60e565ce58983085d07c3d0c456f1a Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Mon, 24 Jul 2023 20:39:34 +0000 Subject: [PATCH] feat(x/swingset): allow taking snapshot latest height --- .../keeper/swing_store_exports_handler.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go b/golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go index 45ca40b31d37..963bbb0a81ba 100644 --- a/golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go +++ b/golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go @@ -123,9 +123,9 @@ const swingStoreExportActionType = "SWING_STORE_EXPORT" const initiateRequest = "initiate" type swingStoreInitiateExportAction struct { - Type string `json:"type"` // "SWING_STORE_EXPORT" - Request string `json:"request"` // "initiate" - BlockHeight uint64 `json:"blockHeight"` // expected blockHeight + Type string `json:"type"` // "SWING_STORE_EXPORT" + Request string `json:"request"` // "initiate" + BlockHeight uint64 `json:"blockHeight,omitempty"` // empty if no blockHeight requested (latest) } // retrieveRequest is the request type for retrieving an initiated export @@ -399,7 +399,12 @@ func (exportsHandler SwingStoreExportsHandler) InitiateExport(blockHeight uint64 return err } - logger := exportsHandler.logger.With("height", blockHeight) + var logger log.Logger + if blockHeight != 0 { + logger = exportsHandler.logger.With("height", blockHeight) + } else { + logger = exportsHandler.logger.With("height", "latest") + } // Indicate that an export operation has been initiated by setting the global // activeOperation var. @@ -564,7 +569,7 @@ func (exportsHandler SwingStoreExportsHandler) retrieveExport(onExportRetrieved return err } - if manifest.BlockHeight != blockHeight { + if blockHeight != 0 && manifest.BlockHeight != blockHeight { return fmt.Errorf("export manifest blockHeight (%d) doesn't match (%d)", manifest.BlockHeight, blockHeight) }