Skip to content

Commit

Permalink
Add mana calculations (#1376)
Browse files Browse the repository at this point in the history
* Add Mana decay computation

* fix up the mana decay fn

* add potential mana calculation

* refactor

* rename

* make epoch/slot conversion simple

* cleanup

* impl Into

* clippy

* Add tests

* revert functionality and comment out tests that cannot pass

* revert to non-wrapping lower_n_bits

* okay one more check

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Oct 13, 2023
1 parent ac80cc9 commit de89ba4
Show file tree
Hide file tree
Showing 8 changed files with 523 additions and 141 deletions.
4 changes: 2 additions & 2 deletions sdk/src/client/api/block_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl ClientInner {

let protocol_params = self.get_protocol_parameters().await?;

Ok(BlockWrapper::build(
BlockWrapper::build(
BlockHeader::new(
protocol_params.version(),
protocol_params.network_id(),
Expand All @@ -66,6 +66,6 @@ impl ClientInner {
.finish_block()?,
)
.sign_ed25519(secret_manager, chain)
.await?)
.await
}
}
7 changes: 7 additions & 0 deletions sdk/src/types/block/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ pub enum Error {
DuplicateOutputChain(ChainId),
InvalidField(&'static str),
NullDelegationValidatorId,
InvalidEpochDelta {
created: EpochIndex,
target: EpochIndex,
},
}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -375,6 +379,9 @@ impl fmt::Display for Error {
Self::DuplicateOutputChain(chain_id) => write!(f, "duplicate output chain {chain_id}"),
Self::InvalidField(field) => write!(f, "invalid field: {field}"),
Self::NullDelegationValidatorId => write!(f, "null delegation validator ID"),
Self::InvalidEpochDelta { created, target } => {
write!(f, "invalid epoch delta: created {created}, target {target}")
}
}
}
}
Expand Down
Loading

0 comments on commit de89ba4

Please sign in to comment.