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

add cbor decoder for HardForkQuery #335

Merged
merged 3 commits into from
Nov 20, 2023
Merged

Conversation

falcucci
Copy link
Contributor

@falcucci falcucci commented Nov 17, 2023

those were missing to make the localstate query test fixtures.

…nd `ledgerquery`

adds the `encode` and `decode` implementations for the `hardforkquery` and `ledgerquery` structs, located in the `pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs` and `pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs` files respectively.
@falcucci falcucci changed the title add epoch number struct and encode/decode implementations for hardforkquery and ledgerquery add epoch number struct and encode/decode Nov 17, 2023
updates the hardforkquery codec, making the `_` case return an error instead of unreachable. this change allows for better error handling in the event of an invalid tag.

```diff
diff --git a/pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs b/pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
index 7abe225e4e8e..2e518b685e69 100644
--- a/pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
+++ b/pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
@@ -178,7 +178,7 @@ impl<'b> decode<'b, ()> for hardforkquery {
         match tag {
             0 => ok(self::getinterpreter),
             1 => ok(self::getcurrentera),
-            _ => unreachable!(),
+            _ => err(decode::error::message("invalid tag")),
         }
     }
 }
```
@falcucci falcucci changed the title add epoch number struct and encode/decode add epoch number struct and cbor decoder for HardForkQuery Nov 17, 2023
@falcucci falcucci marked this pull request as ready for review November 17, 2023 01:06
@falcucci falcucci changed the title add epoch number struct and cbor decoder for HardForkQuery add cbor decoder for HardForkQuery Nov 17, 2023
@scarmuega scarmuega merged commit 9b57b0f into txpipe:main Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants