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:
Chris Stewart 2021-01-07 07:40:30 -06:00 committed by GitHub
parent 2e68cd4232
commit dc73cb26ff
5 changed files with 9 additions and 9 deletions

View file

@ -54,7 +54,7 @@ object BitcoindRpcBackendUtil extends BitcoinSLogger {
for {
bitcoindHeight <- bitcoind.getBlockCount
walletStateOpt <- wallet.getSyncHeight()
walletStateOpt <- wallet.getSyncDescriptorOpt()
_ <- walletStateOpt match {
case None =>
for {

View file

@ -72,7 +72,7 @@ class BitcoindBackendTest extends BitcoinSAsyncTest with EmbeddedPg {
height <- bitcoind.getBlockCount
bestHash <- bitcoind.getBestBlockHash
syncHeightOpt <- wallet.getSyncHeight()
syncHeightOpt <- wallet.getSyncDescriptorOpt()
} yield {
assert(balance == amountToSend)
assert(syncHeightOpt.contains(SyncHeightDescriptor(bestHash, height)))

View file

@ -35,7 +35,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
height <- bitcoind.getBlockCount
bestHash <- bitcoind.getBestBlockHash
syncHeightOpt <- wallet.getSyncHeight()
syncHeightOpt <- wallet.getSyncDescriptorOpt()
} yield {
assert(utxos.size == 1)
assert(utxos.head.output.scriptPubKey == addr.scriptPubKey)
@ -63,7 +63,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
height <- bitcoind.getBlockCount
bestHash <- bitcoind.getBestBlockHash
syncHeightOpt <- wallet.getSyncHeight()
syncHeightOpt <- wallet.getSyncDescriptorOpt()
} yield {
assert(utxos.size == 100)
assert(balance == Bitcoins(50))
@ -91,7 +91,7 @@ class ProcessBlockTest extends BitcoinSWalletTest {
height <- bitcoind.getBlockCount
bestHash <- bitcoind.getBestBlockHash
syncHeightOpt <- wallet.getSyncHeight()
syncHeightOpt <- wallet.getSyncDescriptorOpt()
} yield {
assert(utxos.size == 100)
assert(balance == Bitcoins(50))

View file

@ -157,8 +157,8 @@ abstract class Wallet
}
}
def getSyncHeight(): Future[Option[SyncHeightDescriptor]] = {
stateDescriptorDAO.getSyncHeightOpt()
def getSyncDescriptorOpt(): Future[Option[SyncHeightDescriptor]] = {
stateDescriptorDAO.getSyncDescriptorOpt()
}
override def processCompactFilters(

View file

@ -55,7 +55,7 @@ case class WalletStateDescriptorDAO()(implicit
Seq] =
findByPrimaryKeys(ts.map(_.tpe))
def getSyncHeightOpt(): Future[Option[SyncHeightDescriptor]] = {
def getSyncDescriptorOpt(): Future[Option[SyncHeightDescriptor]] = {
read(SyncHeight).map {
case Some(db) =>
val desc = SyncHeightDescriptor.fromString(db.descriptor.toString)
@ -67,7 +67,7 @@ case class WalletStateDescriptorDAO()(implicit
def updateSyncHeight(
hash: DoubleSha256DigestBE,
height: Int): Future[WalletStateDescriptorDb] = {
getSyncHeightOpt().flatMap {
getSyncDescriptorOpt().flatMap {
case Some(old) =>
if (old.height > height) {
Future.successful(WalletStateDescriptorDb(SyncHeight, old))