Skip to content

Commit

Permalink
feat(iroh-base): allow the addr info of tickets to be empty (#2254)
Browse files Browse the repository at this point in the history
## Description

feat(iroh-base): allow the addr info of tickets to be empty

Without this, a ticket that does not contain any addresses or relay URL
can not be parsed. But we need to allow this if we want to use short
tickets.

## Breaking Changes

<!-- Optional, if there are any breaking changes document them,
including how to migrate older code. -->

## Notes & open questions

Note: I did not remove the error type Validation. That way we don't have
breaking changes, and we might need it again in the future.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
  • Loading branch information
rklaehn authored Apr 30, 2024
1 parent 13a0bbc commit 5502c5a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 6 deletions.
3 changes: 0 additions & 3 deletions iroh-base/src/ticket/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ impl Ticket for BlobTicket {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, ticket::Error> {
let res: TicketWireFormat = postcard::from_bytes(bytes).map_err(ticket::Error::Postcard)?;
let TicketWireFormat::Variant0(res) = res;
if res.node.info.is_empty() {
return Err(ticket::Error::Verify("addressing info cannot be empty"));
}
Ok(res)
}
}
Expand Down
3 changes: 0 additions & 3 deletions iroh-base/src/ticket/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ impl Ticket for NodeTicket {
fn from_bytes(bytes: &[u8]) -> std::result::Result<Self, ticket::Error> {
let res: TicketWireFormat = postcard::from_bytes(bytes).map_err(ticket::Error::Postcard)?;
let TicketWireFormat::Variant0(res) = res;
if res.node.info.is_empty() {
return Err(ticket::Error::Verify("addressing info cannot be empty"));
}
Ok(res)
}
}
Expand Down

0 comments on commit 5502c5a

Please sign in to comment.