Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Notify syncFinished to syncStateListener when peer is synced (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
esen committed Jun 25, 2019
1 parent 9cd93c4 commit a4378f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions BitcoinCore/BitcoinCore/Blocks/InitialBlockDownload.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public class InitialBlockDownload {
syncedPeers.append(peer)

subject.onNext(.onPeerSynced(peer: peer))
syncStateListener.syncFinished()
}

private func setPeerNotSynced(_ peer: IPeer) {
Expand Down
4 changes: 4 additions & 0 deletions BitcoinCore/BitcoinCore/Core/KitStateProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ extension KitStateProvider: ISyncStateListener {
currentBestBlockHeight = height
}

func syncFinished() {
syncState = .synced
}

func currentBestBlockHeightUpdated(height: Int32, maxBlockHeight: Int32) {
if currentBestBlockHeight < height {
currentBestBlockHeight = height
Expand Down
1 change: 1 addition & 0 deletions BitcoinCore/BitcoinCore/Core/Protocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ protocol IConnectionTimeoutManager: class {
}

protocol ISyncStateListener: class {
func syncFinished()
func syncStarted()
func syncStopped()
func initialBestBlockHeightUpdated(height: Int32)
Expand Down

0 comments on commit a4378f7

Please sign in to comment.