Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE-2652 Lazy GRPC API response #3934

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class TransactionsApiGrpcImpl(blockchain: Blockchain, commonApi: CommonTransacti

// By ids
case None =>
Observable.fromIterable(transactionIds.flatMap(commonApi.transactionById))
for {
id <- Observable.fromIterable(transactionIds)
tx <- Observable.fromIterable(commonApi.transactionById(id))
} yield tx
}

val transactionIdSet = transactionIds.toSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ object CommonBlocksApi {
.flatMap(Observable.fromIterable(_))

def blocksRange(fromHeight: Int, toHeight: Int, generatorAddress: Address): Observable[(BlockMeta, Seq[(TxMeta, Transaction)])] =
Observable.fromIterable(
(fixHeight(fromHeight) to fixHeight(toHeight))
.flatMap(h => metaAt(h))
.collect { case m if m.header.generator.toAddress == generatorAddress => m.height }
.flatMap(h => blockInfoAt(h))
)
for {
height <- Observable.fromIterable(fixHeight(fromHeight) to fixHeight(toHeight))
meta <- Observable.fromIterable(metaAt(height)) if meta.header.generator.toAddress == generatorAddress
block <- Observable.fromIterable(blockInfoAt(meta.height))
} yield block

def blockDelay(blockId: BlockId, blockNum: Int): Option[Long] =
blockchain
Expand All @@ -75,7 +74,10 @@ object CommonBlocksApi {
def meta(id: ByteStr): Option[BlockMeta] = blockchain.heightOf(id).flatMap(metaAt)

def metaRange(fromHeight: Int, toHeight: Int): Observable[BlockMeta] =
Observable.fromIterable((fixHeight(fromHeight) to fixHeight(toHeight)).flatMap(h => metaAt(h)))
for {
height <- Observable.fromIterable(fixHeight(fromHeight) to fixHeight(toHeight))
meta <- Observable.fromIterable(metaAt(height))
} yield meta

def block(blockId: BlockId): Option[(BlockMeta, Seq[(TxMeta, Transaction)])] = blockchain.heightOf(blockId).flatMap(h => blockInfoAt(h))
}
Expand Down