Fix address tag issue where we weren't adding tags to an address, we were replacing existing tags (#1824)

This commit is contained in:
Chris Stewart 2020-08-14 10:06:28 -05:00 committed by GitHub
parent 48a7f6f86e
commit 2445003503
2 changed files with 6 additions and 4 deletions

View file

@ -128,10 +128,11 @@ abstract class CRUD[T, PrimaryKeyType](implicit
* @return t - the record that has been inserted / updated
*/
def upsert(t: T): Future[T] = {
upsertAll(Vector(t)).map { ts =>
upsertAll(Vector(t)).flatMap { ts =>
ts.headOption match {
case Some(updated) => updated
case None => throw UpsertFailedException("Upsert failed for: " + t)
case Some(updated) => Future.successful(updated)
case None =>
Future.failed(UpsertFailedException("Upsert failed for: " + t))
}
}
}

View file

@ -410,7 +410,8 @@ private[wallet] trait AddressHandling extends WalletLogger {
address: BitcoinAddress,
tag: AddressTag): Future[AddressTagDb] = {
val addressTagDb = AddressTagDb(address, tag)
addressTagDAO.upsert(addressTagDb)
val f = addressTagDAO.create(addressTagDb)
f
}
def getAddressTags(address: BitcoinAddress): Future[Vector[AddressTagDb]] = {