Skip to content

Commit 09fde88

Browse files
committed
Update lastBlockInfo after each sync in BlockchairApiSyncer
1 parent 945cf2c commit 09fde88

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

Sources/BitcoinCore/Classes/ApiSync/BlockchairSync/BlockchairApiSyncer.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,29 @@ class BlockchairApiSyncer {
112112
private func handle(error: Error) {
113113
listener?.onSyncFailed(error: error)
114114
}
115-
}
116115

117-
extension BlockchairApiSyncer: IApiSyncer {
118-
var willSync: Bool {
119-
true
120-
}
121-
122-
func sync() {
116+
private func syncLastBlock() {
123117
Task { [weak self] in
124118
do {
125-
try await self?.scan()
119+
try await self?._syncLastBlock()
126120
} catch {
127121
self?.handle(error: error)
128122
}
129123
}
130124
.store(in: &tasks)
131125
}
126+
}
132127

133-
func syncLastBlock() {
128+
extension BlockchairApiSyncer: IApiSyncer {
129+
var willSync: Bool {
130+
true
131+
}
132+
133+
func sync() {
134134
Task { [weak self] in
135135
do {
136-
try await self?._syncLastBlock()
136+
try await self?.scan()
137+
self?.syncLastBlock()
137138
} catch {
138139
self?.handle(error: error)
139140
}

Sources/BitcoinCore/Classes/ApiSync/LegacySync/ApiSyncer.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ extension ApiSyncer: IApiSyncer {
9191
Task { [weak self] in await self?._sync() }.store(in: &tasks)
9292
}
9393

94-
func syncLastBlock() {}
95-
9694
func terminate() {
9795
tasks = Set()
9896
}

Sources/BitcoinCore/Classes/Core/Protocols.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ protocol IApiSyncer {
295295
var listener: IApiSyncerListener? { get set }
296296
var willSync: Bool { get }
297297
func sync()
298-
func syncLastBlock()
299298
func terminate()
300299
}
301300

Sources/BitcoinCore/Classes/Managers/SyncManager.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ extension SyncManager: IBlockSyncListener {
213213
let forceAddedBlocks = forceAddedBlocksTotal - storage.apiBlockHashesCount
214214

215215
if forceAddedBlocks >= forceAddedBlocksTotal {
216-
apiSyncer.syncLastBlock()
217216
syncState = .synced
218217
} else {
219218
syncState = .syncing(progress: Double(forceAddedBlocks) / Double(forceAddedBlocksTotal))

0 commit comments

Comments
 (0)