- attached to the processor's timer
- added latest scanned time and latest block height
- sample app showing the new values alongside with the %
- unit tests fixed
- latestBlock() API added
- the transaction repository is no longer used to update the exposed values during the syncing
Closes#895
Add Sync Session ID to `SynchronizerState`.
A SyncSession is an attempt to sync the blockchain within the lifetime of a Synchronizer.
A Synchronizer can sync many times, when synced it will refresh every ~20 seconds +- random padding.
each sync attempt will have a different UUID even if it's from the same instance of SDKSynchronizer.
**How are SyncSessions are delimited? With `SyncStatus` changes.**
changes from [`.unprepared`|`.error`|`.disconnected`|`.stopped`] to `.syncing` assign a new sessionID to the synchronizer.
Any other transitions won't.
`areTwoStatusesDifferent ` was refactored to a helper function of `SyncStatus`
**How are IDs generated?**
ID generation is not mandated but delegated to a protocol `SyncSessionIDGenerator`.
Tests inject their own deterministic generator to avoid test flakiness.
Default implementation of SyncSessionIDGenerator is
````Swift
struct UniqueSyncSessionIDGenerator {}
extension UniqueSyncSessionIDGenerator: SyncSessionIDGenerator {
func nextID() -> UUID {
UUID()
}
}
````
**SyncSession Pseudo-Atomicity and thread safety**
SyncSession is a type alias of a GenericActor holding a UUID
````
typealias SyncSession = GenericActor<UUID>
extension SyncSession {
/// updates the current sync session to a new value with the given generator
/// - Parameters generator: a `SyncSessionIDGenerator`
/// - returns: the `UUID` of the newly updated value.
@discardableResult
func newSession(with generator: SyncSessionIDGenerator) async -> UUID {
return await self.update(generator.nextID())
}
}
````
Closes#895
SessionTicker struct to control session transitions.
switching to `.unprepared` now makes syncID to be `.nullID`