revert formatting nostr

This commit is contained in:
dni ⚡ 2023-03-19 11:15:26 +01:00
parent bb1941445d
commit 4549d0af09
No known key found for this signature in database
GPG key ID: 886317704CC4E618
11 changed files with 48 additions and 71 deletions

View file

@ -1,9 +1,7 @@
import time
from .event import Event
from .key import PrivateKey
def zero_bits(b: int) -> int:
n = 0
@ -16,11 +14,10 @@ def zero_bits(b: int) -> int:
return 7 - n
def count_leading_zero_bits(hex_str: str) -> int:
total = 0
for i in range(0, len(hex_str) - 2, 2):
bits = zero_bits(int(hex_str[i : i + 2], 16))
bits = zero_bits(int(hex_str[i:i+2], 16))
total += bits
if bits != 8:
@ -28,10 +25,7 @@ def count_leading_zero_bits(hex_str: str) -> int:
return total
def mine_event(
content: str, difficulty: int, public_key: str, kind: int, tags: list = []
) -> Event:
def mine_event(content: str, difficulty: int, public_key: str, kind: int, tags: list=[]) -> Event:
all_tags = [["nonce", "1", str(difficulty)]]
all_tags.extend(tags)
@ -49,7 +43,6 @@ def mine_event(
return Event(public_key, content, created_at, kind, all_tags, event_id)
def mine_key(difficulty: int) -> PrivateKey:
sk = PrivateKey()
num_leading_zero_bits = count_leading_zero_bits(sk.public_key.hex())