mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-24 06:57:51 +01:00
Call syncwithvalidationinterfacequeue
inside of {generatetoaddress,generateblock}
(#4987)
* Call syncwithvalidationinterfacequeue inside of generatetoaddress,generateblock to guarantee that bitcoind is internally consistent before we do other things against it * Empty commit * Empty commit to re-run CI
This commit is contained in:
parent
46d3079e5b
commit
ff8376ceb6
1 changed files with 12 additions and 3 deletions
|
@ -18,15 +18,20 @@ import scala.concurrent.Future
|
|||
|
||||
/** RPC calls related to mining
|
||||
*/
|
||||
trait MiningRpc { self: Client =>
|
||||
trait MiningRpc { self: Client with BlockchainRpc =>
|
||||
|
||||
def generateToAddress(
|
||||
blocks: Int,
|
||||
address: BitcoinAddress,
|
||||
maxTries: Int = 1000000): Future[Vector[DoubleSha256DigestBE]] = {
|
||||
bitcoindCall[Vector[DoubleSha256DigestBE]](
|
||||
val hashesF = bitcoindCall[Vector[DoubleSha256DigestBE]](
|
||||
"generatetoaddress",
|
||||
List(JsNumber(blocks), JsString(address.toString), JsNumber(maxTries)))
|
||||
|
||||
for {
|
||||
hashes <- hashesF
|
||||
_ <- syncWithValidationInterfaceQueue()
|
||||
} yield hashes
|
||||
}
|
||||
|
||||
def generateBlock(
|
||||
|
@ -34,9 +39,13 @@ trait MiningRpc { self: Client =>
|
|||
transactions: Vector[Transaction]
|
||||
): Future[DoubleSha256DigestBE] = {
|
||||
val txsJs = JsArray(transactions.map(t => JsString(t.hex)))
|
||||
bitcoindCall[GenerateBlockResult](
|
||||
val hashesF = bitcoindCall[GenerateBlockResult](
|
||||
"generateblock",
|
||||
List(JsString(address.toString), txsJs)).map(_.hash)
|
||||
for {
|
||||
hash <- hashesF
|
||||
_ <- syncWithValidationInterfaceQueue()
|
||||
} yield hash
|
||||
}
|
||||
|
||||
def getBlockTemplate(request: Option[RpcOpts.BlockTemplateRequest] =
|
||||
|
|
Loading…
Add table
Reference in a new issue