Skip to content

Commit

Permalink
Use VLQ varints in payload (casey#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Sep 28, 2023
1 parent 51493b1 commit 7f6404e
Show file tree
Hide file tree
Showing 5 changed files with 525 additions and 395 deletions.
8 changes: 8 additions & 0 deletions src/directive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use super::*;

#[derive(Default, Serialize, Debug, PartialEq)]
pub struct Directive {
pub id: u128,
pub amount: u128,
pub output: u128,
}
26 changes: 26 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use super::*;

#[derive(Debug, PartialEq)]
pub enum Error {
Script(script::Error),
Opcode(opcodes::All),
Varint,
}

impl From<script::Error> for Error {
fn from(error: script::Error) -> Self {
Self::Script(error)
}
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::Script(err) => write!(f, "failed to parse script: {err}"),
Self::Opcode(op) => write!(f, "non-push opcode {op} in payload"),
Self::Varint => write!(f, "varint over maximum value"),
}
}
}

impl std::error::Error for Error {}
Loading

0 comments on commit 7f6404e

Please sign in to comment.