From 4d65f622f31e740df113da7c2b79aee4a82814ff Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Fri, 11 Feb 2022 15:09:08 +0300 Subject: [PATCH] Handle zero number of versions in PersistentBatchAVLProver --- .../authds/avltree/batch/PersistentBatchAVLProver.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/scala/scorex/crypto/authds/avltree/batch/PersistentBatchAVLProver.scala b/src/main/scala/scorex/crypto/authds/avltree/batch/PersistentBatchAVLProver.scala index b9d8d29b..18bd9e8b 100644 --- a/src/main/scala/scorex/crypto/authds/avltree/batch/PersistentBatchAVLProver.scala +++ b/src/main/scala/scorex/crypto/authds/avltree/batch/PersistentBatchAVLProver.scala @@ -55,8 +55,11 @@ object PersistentBatchAVLProver { case Some(ver) => rollback(ver).get case None => generateProofAndUpdateStorage(additionalData) //to initialize storage and clear prover's state }).ensuring { _ => - storage.version.get.sameElements(avlProver.digest) && - (!paranoidChecks || Try(avlProver.checkTree(true)).isSuccess) + storage.version match { + case Some(ver) => ver.sameElements(avlProver.digest) && + (!paranoidChecks || Try(avlProver.checkTree(true)).isSuccess) + case None => true + } } } }