Skip to content

Commit db4b120

Browse files
committed
nostr: use EventId::check_pow in EventBuilder::to_unsigned_pow_event_with_supplier
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 263f600 commit db4b120

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/nostr/src/event/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ use crate::nips::nip51::{ArticlesCuration, Bookmarks, Emojis, Interests, MuteLis
3131
use crate::nips::nip53::LiveEvent;
3232
#[cfg(feature = "nip57")]
3333
use crate::nips::nip57::ZapRequestData;
34+
use crate::nips::nip58;
3435
#[cfg(all(feature = "std", feature = "nip59"))]
3536
use crate::nips::nip59;
3637
use crate::nips::nip65::RelayMetadata;
3738
use crate::nips::nip90::DataVendingMachineStatus;
3839
use crate::nips::nip94::FileMetadata;
3940
use crate::nips::nip98::HttpData;
40-
use crate::nips::{nip13, nip58};
4141
#[cfg(feature = "std")]
4242
use crate::types::time::Instant;
4343
use crate::types::time::TimeSupplier;
@@ -303,7 +303,7 @@ impl EventBuilder {
303303
.unwrap_or_else(|| Timestamp::now_with_supplier(supplier));
304304
let id: EventId = EventId::new(&pubkey, &created_at, &self.kind, &tags, &self.content);
305305

306-
if nip13::get_leading_zero_bits(id.as_bytes()) >= difficulty {
306+
if id.check_pow(difficulty) {
307307
#[cfg(feature = "std")]
308308
tracing::debug!(
309309
"{} iterations in {} ms. Avg rate {} hashes/second",

crates/nostr/src/nips/nip13.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn get_leading_zero_bits<T>(h: T) -> u8
1616
where
1717
T: AsRef<[u8]>,
1818
{
19-
let mut res: u8 = 0_u8;
19+
let mut res: u8 = 0u8;
2020
for b in h.as_ref().iter() {
2121
if *b == 0 {
2222
res += 8;

0 commit comments

Comments
 (0)