astreum 0.1.14__py3-none-any.whl → 0.1.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of astreum might be problematic. Click here for more details.

@@ -31,11 +31,11 @@ determined by the difficulty parameter. The nonce is adjusted until this require
31
31
  import struct
32
32
  import time
33
33
  import os
34
- import hashlib
35
34
  from dataclasses import dataclass
36
35
  from typing import Optional, Tuple, List
37
36
  from .message import Message, Topic
38
37
  from astreum.utils.bytes_format import encode, decode
38
+ from ..utils import hash_data
39
39
 
40
40
  @dataclass
41
41
  class Envelope:
@@ -153,13 +153,13 @@ class Envelope:
153
153
  bytes: The Merkle root hash
154
154
  """
155
155
  if not leaves:
156
- return hashlib.sha256(b'').digest()
156
+ return hash_data(b'')
157
157
 
158
158
  if len(leaves) == 1:
159
- return hashlib.sha256(leaves[0]).digest()
159
+ return hash_data(leaves[0])
160
160
 
161
161
  # Hash all leaf nodes
162
- hashed_leaves = [hashlib.sha256(leaf).digest() for leaf in leaves]
162
+ hashed_leaves = [hash_data(leaf) for leaf in leaves]
163
163
 
164
164
  # Build the Merkle tree
165
165
  while len(hashed_leaves) > 1:
@@ -171,7 +171,7 @@ class Envelope:
171
171
  next_level = []
172
172
  for i in range(0, len(hashed_leaves), 2):
173
173
  combined = hashed_leaves[i] + hashed_leaves[i+1]
174
- next_level.append(hashlib.sha256(combined).digest())
174
+ next_level.append(hash_data(combined))
175
175
 
176
176
  hashed_leaves = next_level
177
177
 
@@ -0,0 +1,13 @@
1
+ """
2
+ Storage utilities for the Astreum node.
3
+ """
4
+
5
+ from .merkle import MerkleTree, MerkleProof, MerkleNode
6
+ from .merkle import find_first, find_all, map, binary_search
7
+ from .storage import Storage
8
+
9
+ __all__ = [
10
+ "MerkleTree", "MerkleProof", "MerkleNode",
11
+ "find_first", "find_all", "map", "binary_search",
12
+ "Storage"
13
+ ]