problem: returns processed json for block with tx, instead of original json

rel: #45
This commit is contained in:
Igor Artamonov
2020-11-30 19:40:56 -05:00
parent e09b7a4eee
commit cfd73119f6
5 changed files with 49 additions and 43 deletions

View File

@@ -205,7 +205,7 @@ class TrackEthereumTx(
return Mono.empty()
}
return upstream.getReader()
.blocksByHash().read(tx.status.blockHash)
.blocksByHashParsed().read(tx.status.blockHash)
.map { block ->
setBlockDetails(tx, block)
}.doOnError { t ->

View File

@@ -71,54 +71,37 @@ open class EthereumReader(
tx.json ?: ByteArray(0)
}
val jsonToRaw = Function<Any, ByteArray> { json ->
objectMapper.writeValueAsBytes(json)
}
val blockAsContainer = Function<BlockJson<*>, BlockContainer> { block ->
BlockContainer.from(block.withoutTransactionDetails())
}
val txAsContainer = Function<TransactionJson, TxContainer> { tx ->
TxContainer.from(tx)
}
private val idToBlockHash = Function<BlockId, BlockHash> { id -> BlockHash.from(id.value) }
private val blockHashToId = Function<BlockHash, BlockId> { hash -> BlockId.from(hash) }
private val txHashToId = Function<TransactionId, TxId> { hash -> TxId.from(hash) }
private val idToTxHash = Function<TxId, TransactionId> { id -> TransactionId.from(id.value) }
fun blocksByHash(): Reader<BlockHash, BlockJson<TransactionRefJson>> {
return TransformingReader(
CompoundReader(
RekeyingReader(blockHashToId, caches.getBlocksByHash()),
directReader.blockReader
),
extractBlock
)
}
fun blocksById(): Reader<BlockId, BlockJson<TransactionRefJson>> {
return TransformingReader(
CompoundReader(
caches.getBlocksByHash(),
RekeyingReader(idToBlockHash, directReader.blockReader)
),
extractBlock
)
}
fun blocksByHashAsCont(): Reader<BlockHash, BlockContainer> {
return CompoundReader(
RekeyingReader(blockHashToId, caches.getBlocksByHash()),
directReader.blockReader
)
}
fun blocksByHashParsed(): Reader<BlockHash, BlockJson<TransactionRefJson>> {
return TransformingReader(
blocksByHash(),
blockAsContainer
blocksByHashAsCont(),
extractBlock
)
}
fun blocksByIdParsed(): Reader<BlockId, BlockJson<TransactionRefJson>> {
return TransformingReader(
blocksByIdAsCont(),
extractBlock
)
}
open fun blocksByIdAsCont(): Reader<BlockId, BlockContainer> {
return TransformingReader(
blocksById(),
blockAsContainer
return CompoundReader(
caches.getBlocksByHash(),
RekeyingReader(idToBlockHash, directReader.blockReader)
)
}