Skip to content

Commit

Permalink
fix: broken deseriealization
Browse files Browse the repository at this point in the history
  • Loading branch information
akostylev0 committed Nov 29, 2023
1 parent 1261d26 commit 86139be
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions tonlibjson-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ impl Generator {
if deserialize_number_from_string && deserialize_with.is_empty() {
quote! {
#serialize_with
#[serde(default)]
#[serde(deserialize_with = "deserialize_number_from_string")]
pub #field_name: #field_type
}
Expand Down
4 changes: 3 additions & 1 deletion tonlibjson-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ impl<R : Requestable> Service<R> for Client {

bail!(error)
} else {
let response = serde_json::from_value::<R::Response>(response.data)?;
let data = response.data.clone();
let response = serde_json::from_value::<R::Response>(response.data)
.map_err(|e| anyhow!("deserialization error: {:?}, data: {:?}", e, data))?;

Ok(response)
}
Expand Down
8 changes: 7 additions & 1 deletion tonlibjson-client/src/cursor_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ impl CursorClient {
let id = Cow::from(id);
let client = ConcurrencyMetric::new(client, id.clone());
let (mtx, mrx) = tokio::sync::watch::channel(None);
let mut mc_watcher = mtx.subscribe();

let _self = Self {
id,
Expand All @@ -299,7 +300,12 @@ impl CursorClient {
};

tokio::spawn(_self.last_block_loop(mtx));
tokio::spawn(_self.first_block_loop());
let inner = _self.first_block_loop();
tokio::spawn(async move {
mc_watcher.changed().await.unwrap();

inner.await;
});

_self
}
Expand Down

0 comments on commit 86139be

Please sign in to comment.