mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 22:56:52 +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
|
import system.dispatcher
|
||||||
val atomicPrevCount = new AtomicInteger(prevCount)
|
val atomicPrevCount = new AtomicInteger(prevCount)
|
||||||
val queueSource: Source[Int, SourceQueueWithComplete[Int]] =
|
val queueSource: Source[Int, SourceQueueWithComplete[Int]] =
|
||||||
Source.queue[Int](100, OverflowStrategy.backpressure)
|
Source.queue[Int](16, OverflowStrategy.backpressure)
|
||||||
val numParallelism = FutureUtil.getParallelism
|
val numParallelism = FutureUtil.getParallelism
|
||||||
|
|
||||||
val fetchBlocksFlow =
|
val fetchBlocksFlow =
|
||||||
|
|
|
@ -4,21 +4,22 @@ import org.bitcoins.server.util.{BitcoindPollingCancellable}
|
||||||
|
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
|
|
||||||
/** @param syncF
|
/** @param initSyncF
|
||||||
* the future that will be completed when the synchronization with bitcoind
|
* the future that will be completed when the initial synchronization with
|
||||||
* is complete
|
* 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
|
* @param pollingCancellable
|
||||||
* You can cancel bitcoind polling by calling
|
* You can cancel bitcoind polling by calling
|
||||||
* [[BitcoindPollingCancellabe.cancel()]]
|
* [[BitcoindPollingCancellabe.cancel()]]
|
||||||
*/
|
*/
|
||||||
case class BitcoindSyncState(
|
case class BitcoindSyncState(
|
||||||
syncF: Future[Unit],
|
initSyncF: Future[Unit],
|
||||||
pollingCancellable: BitcoindPollingCancellable
|
pollingCancellable: BitcoindPollingCancellable
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/** Stops syncing and polling bitcoind */
|
/** Stops syncing and polling bitcoind */
|
||||||
def stop(): Future[Unit] = {
|
def stop(): Future[Unit] = {
|
||||||
pollingCancellable.cancel()
|
pollingCancellable.cancel()
|
||||||
syncF
|
initSyncF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ case class BitcoindPollingCancellable(
|
||||||
}
|
}
|
||||||
|
|
||||||
override def isCancelled: Boolean =
|
override def isCancelled: Boolean =
|
||||||
blockPollingCancellable.isCancelled && mempoolPollingCancelable.cancel()
|
blockPollingCancellable.isCancelled && mempoolPollingCancelable.isCancelled
|
||||||
}
|
}
|
||||||
|
|
||||||
object BitcoindPollingCancellabe {
|
object BitcoindPollingCancellabe {
|
||||||
|
|
Loading…
Add table
Reference in a new issue