Skip to content

Commit

Permalink
server: Fix missing transaction time while loading full blocks
Browse files Browse the repository at this point in the history
The full block retrieval API from xsnd assumes that the blocktime
is the same as the transaction time.
  • Loading branch information
AlexITC committed Aug 2, 2019
1 parent 3a2f261 commit 5770575
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 5 additions & 8 deletions server/app/com/xsn/explorer/models/rpc/Transaction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ object Transaction {
val builder = (__ \ 'txid).read[TransactionId] and
(__ \ 'size).read[Size] and
(__ \ 'blockhash).read[Blockhash] and
(__ \ 'time).readNullable[Long] and
(__ \ 'blocktime).readNullable[Long] and
(__ \ 'blocktime).read[Long] and
(__ \ 'confirmations).read[Confirmations] and
(__ \ 'vout).read[List[TransactionVOUT]] and
(__ \ 'vin)
Expand All @@ -32,9 +31,8 @@ object Transaction {
list.flatMap(_.asOpt[TransactionVIN])
}

// TODO: Enfore blocktime and time fields when https://github.com/X9Developers/XSN/issues/72 is fixed.
builder.apply { (id, size, blockHash, time, blockTime, confirmations, vout, vin) =>
Transaction(id, size, blockHash, time.getOrElse(0), blockTime.getOrElse(0), confirmations, vin, vout)
builder.apply { (id, size, blockHash, blockTime, confirmations, vout, vin) =>
Transaction(id, size, blockHash, blockTime, blockTime, confirmations, vin, vout)
}
}

Expand All @@ -45,7 +43,6 @@ object Transaction {
): Reads[Transaction[TransactionVIN]] = {
val builder = (__ \ 'txid).read[TransactionId] and
(__ \ 'size).read[Size] and
(__ \ 'time).readNullable[Long] and
(__ \ 'vout).read[List[TransactionVOUT]] and
(__ \ 'vin)
.readNullable[List[JsValue]]
Expand All @@ -54,8 +51,8 @@ object Transaction {
list.flatMap(_.asOpt[TransactionVIN])
}

builder.apply { (id, size, time, vout, vin) =>
Transaction(id, size, blockhash, time.getOrElse(0), blocktime, confirmations, vin, vout)
builder.apply { (id, size, vout, vin) =>
Transaction(id, size, blockhash, blocktime, blocktime, confirmations, vin, vout)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@
],
"blockhash": "ee5ee42a4f9c106808b8867f9469a47cb7d5fc5f71ec58e56f0bff895ac2b78d",
"height": -1,
"blocktime": 1520276270,
"confirmations": 0
}

0 comments on commit 5770575

Please sign in to comment.