mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-19 13:35:17 +01:00
Rename wallet.getSyncHeight() -> wallet.getSyncDescriptorOpt(). We don't just use height in the descriptor, the hash is just as valuable for connecting to chains (#2479)
This commit is contained in:
parent
1ea4e1b0be
commit
b76be736b8
5 changed files with 9 additions and 9 deletions
|
@ -54,7 +54,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
bitcoindHeight <- bitcoind.getBlockCount
|
bitcoindHeight <- bitcoind.getBlockCount
|
||||||
walletStateOpt <- wallet.getSyncHeight()
|
walletStateOpt <- wallet.getSyncDescriptorOpt()
|
||||||
_ <- walletStateOpt match {
|
_ <- walletStateOpt match {
|
||||||
case None =>
|
case None =>
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -72,7 +72,7 @@ class BitcoindBackendTest extends BitcoinSAsyncTest with EmbeddedPg {
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount
|
height <- bitcoind.getBlockCount
|
||||||
bestHash <- bitcoind.getBestBlockHash
|
bestHash <- bitcoind.getBestBlockHash
|
||||||
syncHeightOpt <- wallet.getSyncHeight()
|
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
||||||
} yield {
|
} yield {
|
||||||
assert(balance == amountToSend)
|
assert(balance == amountToSend)
|
||||||
assert(syncHeightOpt.contains(SyncHeightDescriptor(bestHash, height)))
|
assert(syncHeightOpt.contains(SyncHeightDescriptor(bestHash, height)))
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount
|
height <- bitcoind.getBlockCount
|
||||||
bestHash <- bitcoind.getBestBlockHash
|
bestHash <- bitcoind.getBestBlockHash
|
||||||
syncHeightOpt <- wallet.getSyncHeight()
|
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
||||||
} yield {
|
} yield {
|
||||||
assert(utxos.size == 1)
|
assert(utxos.size == 1)
|
||||||
assert(utxos.head.output.scriptPubKey == addr.scriptPubKey)
|
assert(utxos.head.output.scriptPubKey == addr.scriptPubKey)
|
||||||
|
@ -63,7 +63,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount
|
height <- bitcoind.getBlockCount
|
||||||
bestHash <- bitcoind.getBestBlockHash
|
bestHash <- bitcoind.getBestBlockHash
|
||||||
syncHeightOpt <- wallet.getSyncHeight()
|
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
||||||
} yield {
|
} yield {
|
||||||
assert(utxos.size == 100)
|
assert(utxos.size == 100)
|
||||||
assert(balance == Bitcoins(50))
|
assert(balance == Bitcoins(50))
|
||||||
|
@ -91,7 +91,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
|
||||||
|
|
||||||
height <- bitcoind.getBlockCount
|
height <- bitcoind.getBlockCount
|
||||||
bestHash <- bitcoind.getBestBlockHash
|
bestHash <- bitcoind.getBestBlockHash
|
||||||
syncHeightOpt <- wallet.getSyncHeight()
|
syncHeightOpt <- wallet.getSyncDescriptorOpt()
|
||||||
} yield {
|
} yield {
|
||||||
assert(utxos.size == 100)
|
assert(utxos.size == 100)
|
||||||
assert(balance == Bitcoins(50))
|
assert(balance == Bitcoins(50))
|
||||||
|
|
|
@ -157,8 +157,8 @@ abstract class Wallet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getSyncHeight(): Future[Option[SyncHeightDescriptor]] = {
|
def getSyncDescriptorOpt(): Future[Option[SyncHeightDescriptor]] = {
|
||||||
stateDescriptorDAO.getSyncHeightOpt()
|
stateDescriptorDAO.getSyncDescriptorOpt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override def processCompactFilters(
|
override def processCompactFilters(
|
||||||
|
|
|
@ -55,7 +55,7 @@ case class WalletStateDescriptorDAO()(implicit
|
||||||
Seq] =
|
Seq] =
|
||||||
findByPrimaryKeys(ts.map(_.tpe))
|
findByPrimaryKeys(ts.map(_.tpe))
|
||||||
|
|
||||||
def getSyncHeightOpt(): Future[Option[SyncHeightDescriptor]] = {
|
def getSyncDescriptorOpt(): Future[Option[SyncHeightDescriptor]] = {
|
||||||
read(SyncHeight).map {
|
read(SyncHeight).map {
|
||||||
case Some(db) =>
|
case Some(db) =>
|
||||||
val desc = SyncHeightDescriptor.fromString(db.descriptor.toString)
|
val desc = SyncHeightDescriptor.fromString(db.descriptor.toString)
|
||||||
|
@ -67,7 +67,7 @@ case class WalletStateDescriptorDAO()(implicit
|
||||||
def updateSyncHeight(
|
def updateSyncHeight(
|
||||||
hash: DoubleSha256DigestBE,
|
hash: DoubleSha256DigestBE,
|
||||||
height: Int): Future[WalletStateDescriptorDb] = {
|
height: Int): Future[WalletStateDescriptorDb] = {
|
||||||
getSyncHeightOpt().flatMap {
|
getSyncDescriptorOpt().flatMap {
|
||||||
case Some(old) =>
|
case Some(old) =>
|
||||||
if (old.height > height) {
|
if (old.height > height) {
|
||||||
Future.successful(WalletStateDescriptorDb(SyncHeight, old))
|
Future.successful(WalletStateDescriptorDb(SyncHeight, old))
|
||||||
|
|
Loading…
Add table
Reference in a new issue