Skip to content

Commit

Permalink
config validate as struct method
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Jan 9, 2024
1 parent 4f5eb8f commit 2000bb6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/proof_of_work/config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ struct ProofOfWorkConfig {
n_bits: u8,
}

fn proof_of_work_config_validate(config: ProofOfWorkConfig) {
assert(config.n_bits.into() >= MIN_PROOF_OF_WORK_BITS, 'value proof of work bits to low');
assert(config.n_bits.into() <= MIN_PROOF_OF_WORK_BITS, 'value proof of work bits to big');
#[generate_trait]
impl ProofOfWorkConfigImpl of ProofOfWorkConfigTrait {
fn config_validate(ref self: ProofOfWorkConfig) {
assert(self.n_bits.into() >= MIN_PROOF_OF_WORK_BITS, 'value proof of work bits to low');
assert(self.n_bits.into() <= MAX_PROOF_OF_WORK_BITS, 'value proof of work bits to big');
}
}

0 comments on commit 2000bb6

Please sign in to comment.