Add isEmpty check

This commit is contained in:
chimp1984 2021-11-05 00:37:50 +01:00
parent c600259267
commit 1108e98164
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -129,9 +129,11 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
if (daoStateAsProto.getBlocksList().isEmpty()) {
int chainHeight = daoStateAsProto.getChainHeight();
list = bsqBlocksStorageService.readBlocks(chainHeight);
int heightOfLastBlock = list.getLast().getHeight();
checkArgument(heightOfLastBlock == chainHeight,
"heightOfLastBlock must match chainHeight");
if (!list.isEmpty()) {
int heightOfLastBlock = list.getLast().getHeight();
checkArgument(heightOfLastBlock == chainHeight,
"heightOfLastBlock must match chainHeight");
}
} else {
list = bsqBlocksStorageService.migrateBlocks(daoStateAsProto.getBlocksList());
}