Skip to content

Commit bc02841

Browse files
committed
Skip full block downloading if SPV is not synchronized
1 parent 90b309a commit bc02841

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

nodecore-spv/src/main/java/org/veriblock/spv/model/DownloadStatus.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ enum class DownloadStatus {
1010

1111
fun isDownloading(): Boolean =
1212
DOWNLOADING == this
13+
14+
fun isReady(): Boolean =
15+
READY == this
1316
}

nodecore-spv/src/main/java/org/veriblock/spv/net/PeerEventListener.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,8 @@ class PeerEventListener(
367367
// TODO(warchant): if allBlocksAccepted == false here, block can not be connected or invalid
368368
// maybe ban peer? for now, do nothing
369369

370-
// download full block bodies to manage mempool
370+
// download full block bodies to manage mempool. Skip if SPV is not synchronized
371+
if (!spvContext.spvService.getDownloadStatus().downloadStatus.isReady()) return
371372
try {
372373
val blocksToRequest = ArrayList<BlockRequest>()
373374

0 commit comments

Comments
 (0)