Skip to content

Commit

Permalink
feat(x/swingset): allow taking snapshot latest height
Browse files Browse the repository at this point in the history
  • Loading branch information
mhofman committed Aug 4, 2023
1 parent 2be676a commit 25fc984
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions golang/cosmos/x/swingset/keeper/swing_store_exports_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 25fc984

Please sign in to comment.