feat(rpc): impl debug_getRawReceipts (#2059)

This commit is contained in:
Matthias Seitz
2023-03-31 16:17:45 +02:00
committed by GitHub
parent 4f50f7213b
commit 0d059275e5
3 changed files with 19 additions and 3 deletions

View File

@@ -26,6 +26,12 @@ impl Receipt {
pub fn bloom_slow(&self) -> Bloom {
logs_bloom(self.logs.iter())
}
/// Calculates the bloom filter for the receipt and returns the [ReceiptWithBloom] container
/// type.
pub fn with_bloom(self) -> ReceiptWithBloom {
self.into()
}
}
impl From<Receipt> for ReceiptWithBloom {

View File

@@ -130,7 +130,7 @@ where
DebugApiClient::raw_header(client, block_id).await.unwrap();
DebugApiClient::raw_block(client, block_id).await.unwrap();
DebugApiClient::raw_transaction(client, H256::default()).await.unwrap();
assert!(is_unimplemented(DebugApiClient::raw_receipts(client, block_id).await.err().unwrap()));
DebugApiClient::raw_receipts(client, block_id).await.unwrap();
assert!(is_unimplemented(DebugApiClient::bad_blocks(client).await.err().unwrap()));
}

View File

@@ -183,8 +183,18 @@ where
}
/// Handler for `debug_getRawReceipts`
async fn raw_receipts(&self, _block_id: BlockId) -> RpcResult<Vec<Bytes>> {
Err(internal_rpc_err("unimplemented"))
async fn raw_receipts(&self, block_id: BlockId) -> RpcResult<Vec<Bytes>> {
let receipts = self.client.receipts_by_block(block_id).to_rpc_result()?.unwrap_or_default();
let mut all_receipts = Vec::with_capacity(receipts.len());
for receipt in receipts {
let mut buf = Vec::new();
let receipt = receipt.with_bloom();
receipt.encode(&mut buf);
all_receipts.push(buf.into());
}
Ok(all_receipts)
}
/// Handler for `debug_getBadBlocks`