diff --git a/src/main/scala/rep/storage/verify/verify4Storage.scala b/src/main/scala/rep/storage/verify/verify4Storage.scala index 154ba7f2..1a308223 100644 --- a/src/main/scala/rep/storage/verify/verify4Storage.scala +++ b/src/main/scala/rep/storage/verify/verify4Storage.scala @@ -36,13 +36,19 @@ class verify4Storage(ctx:RepChainSystemContext) { val fls = new Array[(Int,Long,Long)](fno+1) var i : Int = 0 while(i <= fno){ - val first = sr.getBlockHeightInFileFirstBlockByFileNo(i).get - var last = blockHeight - if(i < fno){ - last = sr.getBlockHeightInFileFirstBlockByFileNo(i+1).get - 1 + val fileNo = sr.getBlockHeightInFileFirstBlockByFileNo(i) + if (fileNo.isDefined) { + val first = sr.getBlockHeightInFileFirstBlockByFileNo(i).get + var last = blockHeight + if (i < fno) { + last = sr.getBlockHeightInFileFirstBlockByFileNo(i + 1).get - 1 + } + fls(i) = (i, first, last) + i += 1 + } else { + fls(i) = (i, 0, 0) + i += 1 } - fls(i) = (i,first,last) - i += 1 } fls.toSet } @@ -50,10 +56,12 @@ class verify4Storage(ctx:RepChainSystemContext) { private def verfiyFileForFileInfo(firstHeigh:Long,lastHeight:Long,sr: BlockSearcher):Boolean={ var r = true if(lastHeight == firstHeigh){ - if(!verfiyBlockOfFile(firstHeigh,sr)){ - r = false - }else{ - RepLogger.info(RepLogger.System_Logger, s"自检:verfiyBlockOfFile成功,检查高度=${firstHeigh}") + if (firstHeigh != 0) { + if (!verfiyBlockOfFile(firstHeigh, sr)) { + r = false + } else { + RepLogger.info(RepLogger.System_Logger, s"自检:verfiyBlockOfFile成功,检查高度=${firstHeigh}") + } } }else{ val seed = lastHeight-firstHeigh