astreum 0.2.10__py3-none-any.whl → 0.2.11__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.
- astreum/utils/__init__.py +0 -0
- astreum/utils/patricia.py +45 -0
- {astreum-0.2.10.dist-info → astreum-0.2.11.dist-info}/METADATA +1 -1
- {astreum-0.2.10.dist-info → astreum-0.2.11.dist-info}/RECORD +7 -5
- {astreum-0.2.10.dist-info → astreum-0.2.11.dist-info}/WHEEL +0 -0
- {astreum-0.2.10.dist-info → astreum-0.2.11.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.2.10.dist-info → astreum-0.2.11.dist-info}/top_level.txt +0 -0
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import blake3
|
|
2
|
+
from typing import Callable, Dict, List, Optional
|
|
3
|
+
from astreum import format
|
|
4
|
+
|
|
5
|
+
EMPTY_HASH = b"\x00" * 32
|
|
6
|
+
|
|
7
|
+
class PatriciaNode:
|
|
8
|
+
def __init__(
|
|
9
|
+
self,
|
|
10
|
+
key_len: int,
|
|
11
|
+
key_bits: bytes,
|
|
12
|
+
value: bytes,
|
|
13
|
+
children: List[bytes]|None = None
|
|
14
|
+
):
|
|
15
|
+
self.key_len = key_len
|
|
16
|
+
self.key_bits = key_bits
|
|
17
|
+
self.value = value
|
|
18
|
+
self.children = children
|
|
19
|
+
self._hash: bytes | None = None
|
|
20
|
+
|
|
21
|
+
def to_bytes(self) -> bytes:
|
|
22
|
+
key_field = bytes([self.key_len]) + self.key_bits
|
|
23
|
+
return format.encode([key_field, self.value, self.children])
|
|
24
|
+
|
|
25
|
+
@classmethod
|
|
26
|
+
def from_bytes(cls, blob: bytes) -> "PatriciaNode":
|
|
27
|
+
key_field, value, children = format.decode(blob)
|
|
28
|
+
key_len = key_field[0]
|
|
29
|
+
key_bits = key_field[1:]
|
|
30
|
+
return cls(key_len, key_bits, value, children)
|
|
31
|
+
|
|
32
|
+
def hash(self) -> bytes:
|
|
33
|
+
if self._hash is None:
|
|
34
|
+
self._hash = blake3.blake3(self.to_bytes()).digest()
|
|
35
|
+
return self._hash
|
|
36
|
+
|
|
37
|
+
class PatriciaTrie:
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
node_get: Callable[[bytes], Optional[bytes]],
|
|
41
|
+
root_hash: Optional[bytes] = None,
|
|
42
|
+
) -> None:
|
|
43
|
+
self._node_get = node_get
|
|
44
|
+
self.nodes: Dict[bytes, bytes] = {}
|
|
45
|
+
self.root_hash: Optional[bytes] = root_hash
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.11
|
|
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
|
|
@@ -13,8 +13,10 @@ astreum/crypto/x25519.py,sha256=i29v4BmwKRcbz9E7NKqFDQyxzFtJUqN0St9jd7GS1uA,1137
|
|
|
13
13
|
astreum/lispeum/__init__.py,sha256=K-NDzIjtIsXzC9X7lnYvlvIaVxjFcY7WNsgLIE3DH3U,58
|
|
14
14
|
astreum/lispeum/parser.py,sha256=jQRzZYvBuSg8t_bxsbt1-WcHaR_LPveHNX7Qlxhaw-M,1165
|
|
15
15
|
astreum/lispeum/tokenizer.py,sha256=J-I7MEd0r2ZoVqxvRPlu-Afe2ZdM0tKXXhf1R4SxYTo,1429
|
|
16
|
-
astreum
|
|
17
|
-
astreum
|
|
18
|
-
astreum-0.2.
|
|
19
|
-
astreum-0.2.
|
|
20
|
-
astreum-0.2.
|
|
16
|
+
astreum/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
|
+
astreum/utils/patricia.py,sha256=ORz-hpWCOFPrE6FSRSTdryUEh91wrEPchs_v627ziRY,1371
|
|
18
|
+
astreum-0.2.11.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
|
|
19
|
+
astreum-0.2.11.dist-info/METADATA,sha256=0P2F7wntW12ZeXs70_tJL5DpqDg1PXm037bBzkMgg4s,5454
|
|
20
|
+
astreum-0.2.11.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
astreum-0.2.11.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
|
|
22
|
+
astreum-0.2.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|