Skip to content

Commit 0738aa1

Browse files
committed
server: added different codec for blocks.
1 parent 3a5ca78 commit 0738aa1

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

server/app/com/xsn/explorer/models/persisted/BlockHeader.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ object BlockHeader {
9999
"nonce" -> obj.nonce,
100100
"bits" -> obj.bits,
101101
"filter" -> filterMaybe,
102+
"difficulty" -> obj.difficulty
103+
)
104+
}
105+
106+
val blockWrites: Writes[BlockHeader] = (obj: BlockHeader) => {
107+
Json.obj(
108+
"hash" -> obj.hash,
109+
"previousBlockhash" -> obj.previousBlockhash,
110+
"nextBlockhash" -> obj.nextBlockhash,
111+
"merkleRoot" -> obj.merkleRoot,
112+
"height" -> obj.height,
113+
"time" -> obj.time,
102114
"difficulty" -> obj.difficulty,
103115
"transactions" -> obj.transactions
104116
)

server/app/controllers/BlocksController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BlocksController @Inject()(
3333
}
3434

3535
def getBlocks(lastSeenHash: Option[String], limit: Int, orderingCondition: String) = public { _ =>
36-
implicit val codec: Writes[BlockHeader] = BlockHeader.partialWrites
36+
implicit val codec: Writes[BlockHeader] = BlockHeader.blockWrites
3737
blockService
3838
.getBlocks(Limit(limit), lastSeenHash, orderingCondition)
3939
.toFutureOr

0 commit comments

Comments
 (0)