mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 06:45:21 +01:00
refactor: Improve bitcoind wallet polling logic (#5834)
This commit is contained in:
parent
dee3a1cdee
commit
788b99c184
3 changed files with 8 additions and 7 deletions
|
@ -501,7 +501,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
|
|||
import system.dispatcher
|
||||
val atomicPrevCount = new AtomicInteger(prevCount)
|
||||
val queueSource: Source[Int, SourceQueueWithComplete[Int]] =
|
||||
Source.queue[Int](100, OverflowStrategy.backpressure)
|
||||
Source.queue[Int](16, OverflowStrategy.backpressure)
|
||||
val numParallelism = FutureUtil.getParallelism
|
||||
|
||||
val fetchBlocksFlow =
|
||||
|
|
|
@ -4,21 +4,22 @@ import org.bitcoins.server.util.{BitcoindPollingCancellable}
|
|||
|
||||
import scala.concurrent.Future
|
||||
|
||||
/** @param syncF
|
||||
* the future that will be completed when the synchronization with bitcoind
|
||||
* is complete
|
||||
/** @param initSyncF
|
||||
* the future that will be completed when the initial synchronization with
|
||||
* bitcoind is complete. This Future isn't related to subsequent polling jobs
|
||||
* after our initial sync between bitcoind and the wallet on startup
|
||||
* @param pollingCancellable
|
||||
* You can cancel bitcoind polling by calling
|
||||
* [[BitcoindPollingCancellabe.cancel()]]
|
||||
*/
|
||||
case class BitcoindSyncState(
|
||||
syncF: Future[Unit],
|
||||
initSyncF: Future[Unit],
|
||||
pollingCancellable: BitcoindPollingCancellable
|
||||
) {
|
||||
|
||||
/** Stops syncing and polling bitcoind */
|
||||
def stop(): Future[Unit] = {
|
||||
pollingCancellable.cancel()
|
||||
syncF
|
||||
initSyncF
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ case class BitcoindPollingCancellable(
|
|||
}
|
||||
|
||||
override def isCancelled: Boolean =
|
||||
blockPollingCancellable.isCancelled && mempoolPollingCancelable.cancel()
|
||||
blockPollingCancellable.isCancelled && mempoolPollingCancelable.isCancelled
|
||||
}
|
||||
|
||||
object BitcoindPollingCancellabe {
|
||||
|
|
Loading…
Add table
Reference in a new issue