astreum 0.1.20__py3-none-any.whl → 0.2.1__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/__init__.py +1 -2
- astreum/{node → _node}/relay/envelope.py +1 -1
- astreum/{node → _node}/relay/message.py +1 -1
- astreum/{node → _node}/storage/merkle.py +3 -3
- astreum/{node → _node}/storage/patricia.py +3 -3
- astreum/{node → _node}/storage/storage.py +2 -0
- astreum/{node → _node}/utils.py +1 -1
- astreum/{node → _node}/validation/account.py +3 -3
- astreum/{node → _node}/validation/transaction.py +3 -3
- astreum/lispeum/__init__.py +2 -0
- astreum/lispeum/parser.py +1 -1
- astreum/machine/environment.py +0 -25
- astreum/node.py +1021 -0
- astreum-0.2.1.dist-info/METADATA +123 -0
- astreum-0.2.1.dist-info/RECORD +57 -0
- {astreum-0.1.20.dist-info → astreum-0.2.1.dist-info}/WHEEL +1 -1
- astreum/utils/__init__.py +0 -0
- astreum-0.1.20.dist-info/METADATA +0 -90
- astreum-0.1.20.dist-info/RECORD +0 -57
- /astreum/{node → _node}/__init__.py +0 -0
- /astreum/{node → _node}/relay/__init__.py +0 -0
- /astreum/{node → _node}/relay/bucket.py +0 -0
- /astreum/{node → _node}/relay/peer.py +0 -0
- /astreum/{node → _node}/relay/route.py +0 -0
- /astreum/{node/crypto → _node/storage}/__init__.py +0 -0
- /astreum/{node → _node}/storage/utils.py +0 -0
- /astreum/{node/storage → _node/validation}/__init__.py +0 -0
- /astreum/{node/validation → _node/validation/_block}/__init__.py +0 -0
- /astreum/{node → _node}/validation/_block/create.py +0 -0
- /astreum/{node → _node}/validation/_block/model.py +0 -0
- /astreum/{node → _node}/validation/_block/validate.py +0 -0
- /astreum/{node → _node}/validation/block.py +0 -0
- /astreum/{node → _node}/validation/constants.py +0 -0
- /astreum/{node → _node}/validation/stake.py +0 -0
- /astreum/{node → _node}/validation/vdf.py +0 -0
- /astreum/{node/validation/_block → crypto}/__init__.py +0 -0
- /astreum/{node/crypto → crypto}/ed25519.py +0 -0
- /astreum/{node/crypto → crypto}/x25519.py +0 -0
- /astreum/{utils/bytes_format.py → format.py} +0 -0
- {astreum-0.1.20.dist-info → astreum-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.1.20.dist-info → astreum-0.2.1.dist-info}/top_level.txt +0 -0
astreum/__init__.py
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
from
|
|
2
|
-
from .node import Node
|
|
1
|
+
from node import Node
|
|
@@ -34,7 +34,7 @@ import os
|
|
|
34
34
|
from dataclasses import dataclass
|
|
35
35
|
from typing import Optional, Tuple, List
|
|
36
36
|
from .message import Message, Topic
|
|
37
|
-
from astreum.
|
|
37
|
+
from astreum.format import encode, decode
|
|
38
38
|
from ..utils import hash_data
|
|
39
39
|
|
|
40
40
|
@dataclass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import blake3
|
|
2
2
|
from .storage import Storage
|
|
3
|
-
from astreum
|
|
3
|
+
from astreum import format
|
|
4
4
|
|
|
5
5
|
class MerkleNode:
|
|
6
6
|
def __init__(self, leaf: bool, data: bytes):
|
|
@@ -27,7 +27,7 @@ class MerkleNode:
|
|
|
27
27
|
:param data: The serialized node data.
|
|
28
28
|
:return: A new MerkleNode instance.
|
|
29
29
|
"""
|
|
30
|
-
leaf_flag, node_data =
|
|
30
|
+
leaf_flag, node_data = format.decode(data)
|
|
31
31
|
return cls(True if leaf_flag == 1 else False, node_data)
|
|
32
32
|
|
|
33
33
|
@classmethod
|
|
@@ -52,7 +52,7 @@ class MerkleNode:
|
|
|
52
52
|
|
|
53
53
|
:return: The serialized bytes representing the node.
|
|
54
54
|
"""
|
|
55
|
-
return
|
|
55
|
+
return format.encode([1 if self.leaf else 0, self.data])
|
|
56
56
|
|
|
57
57
|
def hash(self) -> bytes:
|
|
58
58
|
"""
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import blake3
|
|
2
2
|
from typing import Optional, List
|
|
3
3
|
from .storage import Storage
|
|
4
|
-
import astreum.
|
|
4
|
+
import astreum.format as format format.decode, format.encode
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
def common_prefix_length(a: bytes, b: bytes) -> int:
|
|
@@ -35,7 +35,7 @@ class PatriciaNode:
|
|
|
35
35
|
Expected format: [key, value, children]
|
|
36
36
|
where children is a list of child node hashes (bytes).
|
|
37
37
|
"""
|
|
38
|
-
decoded =
|
|
38
|
+
decoded = format.decode(data)
|
|
39
39
|
key, value, children = decoded
|
|
40
40
|
return cls(key, value, children)
|
|
41
41
|
|
|
@@ -59,7 +59,7 @@ class PatriciaNode:
|
|
|
59
59
|
|
|
60
60
|
Structure: [key, value, children]
|
|
61
61
|
"""
|
|
62
|
-
return
|
|
62
|
+
return format.encode([self.key, self.value, self.children])
|
|
63
63
|
|
|
64
64
|
def hash(self) -> bytes:
|
|
65
65
|
"""
|
|
@@ -39,6 +39,8 @@ class Storage:
|
|
|
39
39
|
self.pending_requests = {} # hash -> (start_time, event)
|
|
40
40
|
self.request_lock = threading.Lock()
|
|
41
41
|
|
|
42
|
+
|
|
43
|
+
|
|
42
44
|
def put(self, data_hash: bytes, data: bytes) -> bool:
|
|
43
45
|
"""Store data with its hash. Returns True if successful, False if space limit exceeded."""
|
|
44
46
|
data_size = len(data)
|
astreum/{node → _node}/utils.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
from ..storage.patricia import PatriciaTrie
|
|
3
3
|
|
|
4
|
-
import astreum.
|
|
4
|
+
import astreum.format as format
|
|
5
5
|
class Account:
|
|
6
6
|
def __init__(self, public_key: bytes, balance: int, code: bytes, counter: int, data: bytes, secret_key: Optional[bytes] = None):
|
|
7
7
|
"""
|
|
@@ -30,7 +30,7 @@ class Account:
|
|
|
30
30
|
|
|
31
31
|
The public_key (and optional secret_key) must be provided separately.
|
|
32
32
|
"""
|
|
33
|
-
decoded =
|
|
33
|
+
decoded = format.decode(data)
|
|
34
34
|
balance, code, counter, account_data = decoded
|
|
35
35
|
return cls(public_key, balance, code, counter, account_data, secret_key=secret_key)
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ class Account:
|
|
|
40
40
|
|
|
41
41
|
Format: [balance, code, counter, data]
|
|
42
42
|
"""
|
|
43
|
-
return
|
|
43
|
+
return format.encode([
|
|
44
44
|
self.balance,
|
|
45
45
|
self.code,
|
|
46
46
|
self.counter,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Optional
|
|
2
2
|
import time
|
|
3
3
|
from .account import Account, get_account_from_storage
|
|
4
|
-
import astreum.
|
|
4
|
+
import astreum.format as format
|
|
5
5
|
|
|
6
6
|
class Transaction:
|
|
7
7
|
def __init__(
|
|
@@ -36,7 +36,7 @@ class Transaction:
|
|
|
36
36
|
Returns:
|
|
37
37
|
Transaction object
|
|
38
38
|
"""
|
|
39
|
-
decoded =
|
|
39
|
+
decoded = format.decode(data)
|
|
40
40
|
sender_public_key, recipient_public_key, amount, tx_data, counter, timestamp, signature = decoded
|
|
41
41
|
|
|
42
42
|
sender_account = None
|
|
@@ -63,7 +63,7 @@ class Transaction:
|
|
|
63
63
|
|
|
64
64
|
Format: [sender_hash, recipient_hash, amount, data, counter, timestamp, signature]
|
|
65
65
|
"""
|
|
66
|
-
return
|
|
66
|
+
return format.encode([
|
|
67
67
|
self.sender.public_key,
|
|
68
68
|
self.recipient.public_key,
|
|
69
69
|
self.amount,
|
astreum/lispeum/__init__.py
CHANGED
astreum/lispeum/parser.py
CHANGED
astreum/machine/environment.py
CHANGED
|
@@ -2,28 +2,3 @@ from typing import Dict, Optional
|
|
|
2
2
|
from astreum.lispeum.expression import Expr
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
class Environment:
|
|
6
|
-
def __init__(self, parent: 'Environment' = None, node: 'Node' = None):
|
|
7
|
-
self.data: Dict[str, Expr] = {}
|
|
8
|
-
self.parent = parent
|
|
9
|
-
self.node = node
|
|
10
|
-
|
|
11
|
-
def set(self, name: str, value: Expr):
|
|
12
|
-
if self.node:
|
|
13
|
-
self.node.post_global_storage(name, value)
|
|
14
|
-
else:
|
|
15
|
-
self.data[name] = value
|
|
16
|
-
|
|
17
|
-
def get(self, name: str) -> Optional[Expr]:
|
|
18
|
-
if self.node:
|
|
19
|
-
return self.node.query_global_storage(name)
|
|
20
|
-
|
|
21
|
-
if name in self.data:
|
|
22
|
-
return self.data[name]
|
|
23
|
-
elif self.parent:
|
|
24
|
-
return self.parent.get(name)
|
|
25
|
-
else:
|
|
26
|
-
return None
|
|
27
|
-
|
|
28
|
-
def __repr__(self):
|
|
29
|
-
return f"Environment({self.data})"
|