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.
- astreum/lispeum/storage.py +10 -10
- astreum/lispeum/utils.py +17 -0
- astreum/node/__init__.py +333 -552
- astreum/node/relay/envelope.py +5 -5
- astreum/node/storage/__init__.py +13 -0
- astreum/node/storage/merkle.py +734 -0
- astreum/node/{models.py → storage/storage.py} +41 -99
- astreum/node/storage/trie.py +146 -0
- astreum/node/storage/utils.py +137 -0
- astreum/node/utils.py +34 -0
- astreum/node/validation/__init__.py +84 -0
- astreum/node/validation/account.py +874 -0
- astreum/node/validation/block/__init__.py +12 -0
- astreum/node/validation/block/create.py +98 -0
- astreum/node/validation/block/model.py +81 -0
- astreum/node/validation/block/validate.py +196 -0
- astreum/node/validation/constants.py +15 -0
- astreum/node/validation/stake.py +229 -0
- astreum/node/validation/state.py +230 -0
- astreum/node/validation/vdf.py +80 -0
- {astreum-0.1.14.dist-info → astreum-0.1.15.dist-info}/METADATA +2 -1
- {astreum-0.1.14.dist-info → astreum-0.1.15.dist-info}/RECORD +25 -9
- {astreum-0.1.14.dist-info → astreum-0.1.15.dist-info}/LICENSE +0 -0
- {astreum-0.1.14.dist-info → astreum-0.1.15.dist-info}/WHEEL +0 -0
- {astreum-0.1.14.dist-info → astreum-0.1.15.dist-info}/top_level.txt +0 -0
astreum/node/relay/envelope.py
CHANGED
|
@@ -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
|
|
156
|
+
return hash_data(b'')
|
|
157
157
|
|
|
158
158
|
if len(leaves) == 1:
|
|
159
|
-
return
|
|
159
|
+
return hash_data(leaves[0])
|
|
160
160
|
|
|
161
161
|
# Hash all leaf nodes
|
|
162
|
-
hashed_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(
|
|
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
|
+
]
|