Skip to content

Commit

Permalink
Return error when file path is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
lumos42 committed Feb 26, 2024
1 parent 44a4712 commit 10be390
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugin/evm/limit_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ func (lop *limitOrderProcesser) saveMemoryDBSnapshot(acceptedBlockNumber *big.In
start := time.Now()
currentHeadBlock := lop.blockChain.CurrentBlock()

if lop.snapshotFilePath == "" {
return fmt.Errorf("snapshot file path not set")
}

memoryDBCopy, err := lop.memoryDb.GetOrderBookDataCopy()
if err != nil {
return fmt.Errorf("Error in getting memory DB copy: err=%v", err)
Expand Down Expand Up @@ -474,11 +478,9 @@ func (lop *limitOrderProcesser) saveMemoryDBSnapshot(acceptedBlockNumber *big.In

snapshotBytes := buf.Bytes()
// write to snapshot file
if lop.snapshotFilePath != "" {
err = os.WriteFile(lop.snapshotFilePath, snapshotBytes, 0644)
if err != nil {
return fmt.Errorf("Error in writing to snapshot file: err=%v", err)
}
err = os.WriteFile(lop.snapshotFilePath, snapshotBytes, 0644)
if err != nil {
return fmt.Errorf("Error in writing to snapshot file: err=%v", err)
}

lop.snapshotSavedBlockNumber = acceptedBlockNumber.Uint64()
Expand Down

0 comments on commit 10be390

Please sign in to comment.