problem: zero bytes when requesting block with tx
This commit is contained in:
@@ -81,7 +81,7 @@ class EthereumFullBlocksReader(
|
||||
} else {
|
||||
joinWithTransactions(blockSplit.t1, blockSplit.t2, Flux.fromIterable(transactionsData).map { it.json!! })
|
||||
.reduce(ByteBuffer.allocate(block.json.size * 4), accumulate)
|
||||
.map { it.flip().array() }
|
||||
.map(this@EthereumFullBlocksReader::extractContent)
|
||||
.map { json ->
|
||||
BlockContainer(block.height, block.hash, block.difficulty, block.timestamp,
|
||||
true,
|
||||
@@ -95,6 +95,13 @@ class EthereumFullBlocksReader(
|
||||
}
|
||||
}
|
||||
|
||||
fun extractContent(it: ByteBuffer): ByteArray {
|
||||
val pos = it.position()
|
||||
val result = ByteArray(pos)
|
||||
it.flip().get(result, 0, pos)
|
||||
return result
|
||||
}
|
||||
|
||||
fun splitByTransactions(json: ByteArray): Tuple2<ByteArray, ByteArray> {
|
||||
//TODO find a lib that implements Knuth-Morris-Pratt Pattern Matching Algorithm for byte arrays
|
||||
// and reimplement without making a string copy from bytes
|
||||
|
||||
Reference in New Issue
Block a user