astreum 0.1.19__tar.gz → 0.1.20__tar.gz

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.

Files changed (63) hide show
  1. {astreum-0.1.19/src/astreum.egg-info → astreum-0.1.20}/PKG-INFO +1 -1
  2. {astreum-0.1.19 → astreum-0.1.20}/pyproject.toml +1 -1
  3. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/__init__.py +1 -1
  4. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/storage/merkle.py +65 -65
  5. astreum-0.1.20/src/astreum/utils/__init__.py +0 -0
  6. {astreum-0.1.19 → astreum-0.1.20/src/astreum.egg-info}/PKG-INFO +1 -1
  7. astreum-0.1.19/src/astreum/node/storage/__init__.py +0 -13
  8. {astreum-0.1.19 → astreum-0.1.20}/LICENSE +0 -0
  9. {astreum-0.1.19 → astreum-0.1.20}/README.md +0 -0
  10. {astreum-0.1.19 → astreum-0.1.20}/setup.cfg +0 -0
  11. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/__init__.py +0 -0
  12. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/__init__.py +0 -0
  13. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/expression.py +0 -0
  14. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/parser.py +0 -0
  15. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/__init__.py +0 -0
  16. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/definition.py +0 -0
  17. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/__init__.py +0 -0
  18. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/all.py +0 -0
  19. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/any.py +0 -0
  20. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/fold.py +0 -0
  21. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/get.py +0 -0
  22. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/insert.py +0 -0
  23. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/map.py +0 -0
  24. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/position.py +0 -0
  25. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/list/remove.py +0 -0
  26. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/number/__init__.py +0 -0
  27. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/special/number/addition.py +0 -0
  28. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/storage.py +0 -0
  29. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/tokenizer.py +0 -0
  30. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/lispeum/utils.py +0 -0
  31. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/machine/__init__.py +0 -0
  32. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/machine/environment.py +0 -0
  33. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/machine/error.py +0 -0
  34. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/crypto/__init__.py +0 -0
  35. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/crypto/ed25519.py +0 -0
  36. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/crypto/x25519.py +0 -0
  37. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/__init__.py +0 -0
  38. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/bucket.py +0 -0
  39. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/envelope.py +0 -0
  40. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/message.py +0 -0
  41. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/peer.py +0 -0
  42. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/relay/route.py +0 -0
  43. {astreum-0.1.19/src/astreum/node/validation → astreum-0.1.20/src/astreum/node/storage}/__init__.py +0 -0
  44. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/storage/patricia.py +0 -0
  45. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/storage/storage.py +0 -0
  46. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/storage/utils.py +0 -0
  47. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/utils.py +0 -0
  48. {astreum-0.1.19/src/astreum/node/validation/_block → astreum-0.1.20/src/astreum/node/validation}/__init__.py +0 -0
  49. {astreum-0.1.19/src/astreum/utils → astreum-0.1.20/src/astreum/node/validation/_block}/__init__.py +0 -0
  50. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/_block/create.py +0 -0
  51. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/_block/model.py +0 -0
  52. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/_block/validate.py +0 -0
  53. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/account.py +0 -0
  54. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/block.py +0 -0
  55. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/constants.py +0 -0
  56. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/stake.py +0 -0
  57. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/transaction.py +0 -0
  58. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/node/validation/vdf.py +0 -0
  59. {astreum-0.1.19 → astreum-0.1.20}/src/astreum/utils/bytes_format.py +0 -0
  60. {astreum-0.1.19 → astreum-0.1.20}/src/astreum.egg-info/SOURCES.txt +0 -0
  61. {astreum-0.1.19 → astreum-0.1.20}/src/astreum.egg-info/dependency_links.txt +0 -0
  62. {astreum-0.1.19 → astreum-0.1.20}/src/astreum.egg-info/requires.txt +0 -0
  63. {astreum-0.1.19 → astreum-0.1.20}/src/astreum.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astreum
3
- Version: 0.1.19
3
+ Version: 0.1.20
4
4
  Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
5
5
  Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
6
6
  Project-URL: Homepage, https://github.com/astreum/lib
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "astreum"
3
- version = "0.1.19"
3
+ version = "0.1.20"
4
4
  authors = [
5
5
  { name="Roy R. O. Okello", email="roy@stelar.xyz" },
6
6
  ]
@@ -8,7 +8,7 @@ from .relay import Relay, Topic
8
8
  from ..machine import AstreumMachine
9
9
  from .utils import hash_data
10
10
  from .validation.block import Block
11
- from .storage import Storage
11
+ from .storage.storage import Storage
12
12
 
13
13
  class Node:
14
14
  def __init__(self, config: dict):
@@ -1,7 +1,71 @@
1
1
  import blake3
2
2
  from .storage import Storage
3
- import astreum.utils.bytes_format as bytes_format bytes_format.decode, bytes_format.encode
3
+ from astreum.utils import bytes_format
4
4
 
5
+ class MerkleNode:
6
+ def __init__(self, leaf: bool, data: bytes):
7
+ """
8
+ Initialize a Merkle node.
9
+
10
+ For a leaf node, `data` is the actual content to be stored.
11
+ For an internal node, `data` should be the concatenation of the two child hashes.
12
+
13
+ :param leaf: A boolean flag indicating whether this node is a leaf node (True) or an internal node (False).
14
+ :param data: The node's data. For leaves, the stored data; for internal nodes, concatenated child hashes.
15
+ """
16
+ self.leaf = leaf
17
+ self.data = data
18
+ self._hash = None # Cached hash value to avoid recomputation.
19
+
20
+ @classmethod
21
+ def from_bytes(cls, data: bytes) -> 'MerkleNode':
22
+ """
23
+ Deserialize a MerkleNode from its byte representation.
24
+
25
+ The input bytes are expected to be in the Astreum format, containing a leaf flag and node data.
26
+
27
+ :param data: The serialized node data.
28
+ :return: A new MerkleNode instance.
29
+ """
30
+ leaf_flag, node_data = bytes_format.decode(data)
31
+ return cls(True if leaf_flag == 1 else False, node_data)
32
+
33
+ @classmethod
34
+ def from_storage(cls, storage: Storage, hash_value: bytes) -> 'MerkleNode' or None:
35
+ """
36
+ Retrieve and deserialize a MerkleNode from storage using its hash.
37
+
38
+ :param storage: The Storage instance used to retrieve the node.
39
+ :param hash_value: The hash key under which the node is stored.
40
+ :return: A MerkleNode instance if found, otherwise None.
41
+ """
42
+ node_bytes = storage.get(hash_value)
43
+ if node_bytes is None:
44
+ return None
45
+ return cls.from_bytes(node_bytes)
46
+
47
+ def to_bytes(self) -> bytes:
48
+ """
49
+ Serialize the MerkleNode into bytes using the Astreum format.
50
+
51
+ The format encodes a list containing the leaf flag and the node data.
52
+
53
+ :return: The serialized bytes representing the node.
54
+ """
55
+ return bytes_format.encode([1 if self.leaf else 0, self.data])
56
+
57
+ def hash(self) -> bytes:
58
+ """
59
+ Compute (or retrieve a cached) hash of the node using the Blake3 algorithm.
60
+
61
+ For leaf nodes, the hash is computed over the actual data.
62
+ For internal nodes, the hash is computed over the concatenated child hashes.
63
+
64
+ :return: The Blake3 digest of the node's data.
65
+ """
66
+ if self._hash is None:
67
+ self._hash = blake3.blake3(self.data).digest()
68
+ return self._hash
5
69
 
6
70
 
7
71
  class MerkleTree:
@@ -158,67 +222,3 @@ class MerkleTree:
158
222
  return new_node_hash
159
223
 
160
224
 
161
- class MerkleNode:
162
- def __init__(self, leaf: bool, data: bytes):
163
- """
164
- Initialize a Merkle node.
165
-
166
- For a leaf node, `data` is the actual content to be stored.
167
- For an internal node, `data` should be the concatenation of the two child hashes.
168
-
169
- :param leaf: A boolean flag indicating whether this node is a leaf node (True) or an internal node (False).
170
- :param data: The node's data. For leaves, the stored data; for internal nodes, concatenated child hashes.
171
- """
172
- self.leaf = leaf
173
- self.data = data
174
- self._hash = None # Cached hash value to avoid recomputation.
175
-
176
- @classmethod
177
- def from_bytes(cls, data: bytes) -> 'MerkleNode':
178
- """
179
- Deserialize a MerkleNode from its byte representation.
180
-
181
- The input bytes are expected to be in the Astreum format, containing a leaf flag and node data.
182
-
183
- :param data: The serialized node data.
184
- :return: A new MerkleNode instance.
185
- """
186
- leaf_flag, node_data = bytes_format.decode(data)
187
- return cls(True if leaf_flag == 1 else False, node_data)
188
-
189
- @classmethod
190
- def from_storage(cls, storage: Storage, hash_value: bytes) -> 'MerkleNode' or None:
191
- """
192
- Retrieve and deserialize a MerkleNode from storage using its hash.
193
-
194
- :param storage: The Storage instance used to retrieve the node.
195
- :param hash_value: The hash key under which the node is stored.
196
- :return: A MerkleNode instance if found, otherwise None.
197
- """
198
- node_bytes = storage.get(hash_value)
199
- if node_bytes is None:
200
- return None
201
- return cls.from_bytes(node_bytes)
202
-
203
- def to_bytes(self) -> bytes:
204
- """
205
- Serialize the MerkleNode into bytes using the Astreum format.
206
-
207
- The format encodes a list containing the leaf flag and the node data.
208
-
209
- :return: The serialized bytes representing the node.
210
- """
211
- return bytes_format.encode([1 if self.leaf else 0, self.data])
212
-
213
- def hash(self) -> bytes:
214
- """
215
- Compute (or retrieve a cached) hash of the node using the Blake3 algorithm.
216
-
217
- For leaf nodes, the hash is computed over the actual data.
218
- For internal nodes, the hash is computed over the concatenated child hashes.
219
-
220
- :return: The Blake3 digest of the node's data.
221
- """
222
- if self._hash is None:
223
- self._hash = blake3.blake3(self.data).digest()
224
- return self._hash
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: astreum
3
- Version: 0.1.19
3
+ Version: 0.1.20
4
4
  Summary: Python library to interact with the Astreum blockchain and its Lispeum virtual machine.
5
5
  Author-email: "Roy R. O. Okello" <roy@stelar.xyz>
6
6
  Project-URL: Homepage, https://github.com/astreum/lib
@@ -1,13 +0,0 @@
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
- ]
File without changes
File without changes
File without changes