Page MenuHomePhabricator

D18105.diff
No OneTemporary

D18105.diff

diff --git a/chronik/chronik-http/src/electrum.rs b/chronik/chronik-http/src/electrum.rs
--- a/chronik/chronik-http/src/electrum.rs
+++ b/chronik/chronik-http/src/electrum.rs
@@ -142,7 +142,7 @@
message::Notification {
jsonrpc: message::JSONRPC_VERSION.to_string(),
method: nt.method,
- params: Some(Value::Array(vec![nt.result])),
+ params: Some(nt.result),
}
}
@@ -543,10 +543,10 @@
fee
}
-async fn header_json_from_height(
+async fn header_hex_from_height(
blocks: &QueryBlocks<'_>,
height: i32,
-) -> Result<Value, RPCError> {
+) -> Result<String, RPCError> {
let header = blocks.header(height.to_string(), 0).await.map_err(|_| {
RPCError::CustomError(
1,
@@ -554,10 +554,7 @@
)
})?;
- Ok(json!({
- "height": height,
- "hex": hex::encode(header.raw_header),
- }))
+ Ok(hex::encode(header.raw_header))
}
#[rpc_pubsub_impl(name = "blockchain")]
@@ -604,15 +601,22 @@
let blocks: chronik_indexer::query::QueryBlocks<'_> =
indexer.blocks(&node_clone);
- match header_json_from_height(&blocks, block_msg.height)
+ match header_hex_from_height(&blocks, block_msg.height)
.await
{
Err(err) => {
log_chronik!("{err}\n");
break;
}
- Ok(header_json) => {
- if sub.notify(header_json).await.is_err() {
+ Ok(header_hex) => {
+ if sub
+ .notify(json!([{
+ "height": block_msg.height,
+ "hex": header_hex,
+ }]))
+ .await
+ .is_err()
+ {
// Don't log, it's likely a client
// unsubscription or disconnection
break;
@@ -630,7 +634,12 @@
.map_err(|_| RPCError::InternalError)?
.tip_height;
- header_json_from_height(&blocks, tip_height).await
+ let header_hex = header_hex_from_height(&blocks, tip_height).await?;
+
+ Ok(json!({
+ "height": tip_height,
+ "hex": header_hex,
+ }))
}
#[rpc_method(name = "headers.unsubscribe")]

File Metadata

Mime Type
text/plain
Expires
Tue, May 20, 23:01 (4 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5866112
Default Alt Text
D18105.diff (2 KB)

Event Timeline