astreum 0.2.40__py3-none-any.whl → 0.2.41__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.
- astreum/_consensus/__init__.py +4 -0
- astreum/_consensus/account.py +170 -0
- astreum/_consensus/accounts.py +67 -0
- astreum/_consensus/block.py +9 -2
- astreum/_consensus/chain.py +65 -65
- astreum/_consensus/fork.py +99 -99
- astreum/_consensus/genesis.py +141 -0
- astreum/_consensus/receipt.py +11 -1
- astreum/_consensus/setup.py +15 -152
- astreum/_consensus/transaction.py +27 -3
- astreum/_consensus/workers/__init__.py +9 -0
- astreum/_consensus/workers/discovery.py +48 -0
- astreum/_consensus/workers/validation.py +122 -0
- astreum/_consensus/workers/verify.py +63 -0
- astreum/_storage/atom.py +24 -7
- astreum/models/block.py +2 -2
- astreum/node.py +755 -753
- {astreum-0.2.40.dist-info → astreum-0.2.41.dist-info}/METADATA +1 -1
- {astreum-0.2.40.dist-info → astreum-0.2.41.dist-info}/RECORD +22 -28
- astreum/lispeum/__init__.py +0 -0
- astreum/lispeum/environment.py +0 -40
- astreum/lispeum/expression.py +0 -86
- astreum/lispeum/parser.py +0 -41
- astreum/lispeum/tokenizer.py +0 -52
- astreum/models/account.py +0 -91
- astreum/models/accounts.py +0 -34
- astreum/models/transaction.py +0 -106
- astreum/relay/__init__.py +0 -0
- astreum/relay/peer.py +0 -9
- astreum/relay/route.py +0 -25
- astreum/relay/setup.py +0 -58
- {astreum-0.2.40.dist-info → astreum-0.2.41.dist-info}/WHEEL +0 -0
- {astreum-0.2.40.dist-info → astreum-0.2.41.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.2.40.dist-info → astreum-0.2.41.dist-info}/top_level.txt +0 -0
astreum/_storage/atom.py
CHANGED
|
@@ -52,11 +52,11 @@ class Atom:
|
|
|
52
52
|
data = buf[len(ZERO32):]
|
|
53
53
|
return Atom(data=data, next=next_hash, size=len(data))
|
|
54
54
|
|
|
55
|
-
def expr_to_atoms(e: Expr) -> Tuple[bytes, List[Atom]]:
|
|
56
|
-
def symbol(value: str) -> Tuple[bytes, List[Atom]]:
|
|
57
|
-
val = value.encode("utf-8")
|
|
58
|
-
val_atom = Atom.from_data(data=val)
|
|
59
|
-
typ_atom = Atom.from_data(b"symbol", val_atom.object_id())
|
|
55
|
+
def expr_to_atoms(e: Expr) -> Tuple[bytes, List[Atom]]:
|
|
56
|
+
def symbol(value: str) -> Tuple[bytes, List[Atom]]:
|
|
57
|
+
val = value.encode("utf-8")
|
|
58
|
+
val_atom = Atom.from_data(data=val)
|
|
59
|
+
typ_atom = Atom.from_data(b"symbol", val_atom.object_id())
|
|
60
60
|
return typ_atom.object_id(), [val_atom, typ_atom]
|
|
61
61
|
|
|
62
62
|
def bytes(data: bytes) -> Tuple[bytes, List[Atom]]:
|
|
@@ -96,5 +96,22 @@ def expr_to_atoms(e: Expr) -> Tuple[bytes, List[Atom]]:
|
|
|
96
96
|
if isinstance(e, Expr.Error):
|
|
97
97
|
return err(e.topic, e.origin)
|
|
98
98
|
if isinstance(e, Expr.ListExpr):
|
|
99
|
-
return lst(e.elements)
|
|
100
|
-
raise TypeError("unknown Expr variant")
|
|
99
|
+
return lst(e.elements)
|
|
100
|
+
raise TypeError("unknown Expr variant")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def bytes_list_to_atoms(values: List[bytes]) -> Tuple[bytes, List[Atom]]:
|
|
104
|
+
"""Build a forward-ordered linked list of atoms from byte payloads.
|
|
105
|
+
|
|
106
|
+
Returns the head object's hash (ZERO32 if no values) and the atoms created.
|
|
107
|
+
"""
|
|
108
|
+
next_hash = ZERO32
|
|
109
|
+
atoms: List[Atom] = []
|
|
110
|
+
|
|
111
|
+
for value in reversed(values):
|
|
112
|
+
atom = Atom.from_data(data=bytes(value), next_hash=next_hash)
|
|
113
|
+
atoms.append(atom)
|
|
114
|
+
next_hash = atom.object_id()
|
|
115
|
+
|
|
116
|
+
atoms.reverse()
|
|
117
|
+
return (next_hash if values else ZERO32), atoms
|
astreum/models/block.py
CHANGED
|
@@ -4,8 +4,8 @@ from threading import Thread
|
|
|
4
4
|
from typing import List, Dict, Any, Optional, Union
|
|
5
5
|
|
|
6
6
|
from astreum.crypto.wesolowski import vdf_generate, vdf_verify
|
|
7
|
-
from astreum.
|
|
8
|
-
from astreum.
|
|
7
|
+
from astreum._consensus.account import Account
|
|
8
|
+
from astreum._consensus.accounts import Accounts
|
|
9
9
|
from astreum.models.patricia import PatriciaTrie
|
|
10
10
|
from astreum.models.transaction import Transaction
|
|
11
11
|
from ..crypto import ed25519
|