astreum 0.2.45__py3-none-any.whl → 0.2.47__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/parser.py +25 -25
- astreum/_node.py +24 -15
- {astreum-0.2.45.dist-info → astreum-0.2.47.dist-info}/METADATA +1 -1
- {astreum-0.2.45.dist-info → astreum-0.2.47.dist-info}/RECORD +7 -7
- {astreum-0.2.45.dist-info → astreum-0.2.47.dist-info}/WHEEL +0 -0
- {astreum-0.2.45.dist-info → astreum-0.2.47.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.2.45.dist-info → astreum-0.2.47.dist-info}/top_level.txt +0 -0
astreum/_lispeum/parser.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from typing import List, Tuple
|
|
2
|
-
from
|
|
1
|
+
from typing import List, Tuple
|
|
2
|
+
from . import Expr
|
|
3
3
|
|
|
4
4
|
class ParseError(Exception):
|
|
5
5
|
pass
|
|
@@ -27,30 +27,30 @@ def _parse_one(tokens: List[str], pos: int = 0) -> Tuple[Expr, int]:
|
|
|
27
27
|
if tok == ')':
|
|
28
28
|
raise ParseError("unexpected ')'")
|
|
29
29
|
|
|
30
|
-
# try integer → Bytes (variable-length two's complement)
|
|
31
|
-
try:
|
|
32
|
-
n = int(tok)
|
|
33
|
-
# encode as minimal-width signed two's complement, big-endian
|
|
34
|
-
def int_to_min_tc(v: int) -> bytes:
|
|
35
|
-
"""Return the minimal-width signed two's complement big-endian
|
|
36
|
-
byte encoding of integer v. Width expands just enough so that
|
|
37
|
-
decoding with signed=True yields the same value and sign.
|
|
38
|
-
Example: 0 -> b"\x00", 127 -> b"\x7f", 128 -> b"\x00\x80".
|
|
39
|
-
"""
|
|
40
|
-
if v == 0:
|
|
41
|
-
return b"\x00"
|
|
42
|
-
w = 1
|
|
43
|
-
while True:
|
|
44
|
-
try:
|
|
45
|
-
return v.to_bytes(w, "big", signed=True)
|
|
46
|
-
except OverflowError:
|
|
47
|
-
w += 1
|
|
48
|
-
|
|
49
|
-
return Expr.Bytes(int_to_min_tc(n)), pos + 1
|
|
50
|
-
except ValueError:
|
|
51
|
-
return Expr.Symbol(tok), pos + 1
|
|
30
|
+
# try integer → Bytes (variable-length two's complement)
|
|
31
|
+
try:
|
|
32
|
+
n = int(tok)
|
|
33
|
+
# encode as minimal-width signed two's complement, big-endian
|
|
34
|
+
def int_to_min_tc(v: int) -> bytes:
|
|
35
|
+
"""Return the minimal-width signed two's complement big-endian
|
|
36
|
+
byte encoding of integer v. Width expands just enough so that
|
|
37
|
+
decoding with signed=True yields the same value and sign.
|
|
38
|
+
Example: 0 -> b"\x00", 127 -> b"\x7f", 128 -> b"\x00\x80".
|
|
39
|
+
"""
|
|
40
|
+
if v == 0:
|
|
41
|
+
return b"\x00"
|
|
42
|
+
w = 1
|
|
43
|
+
while True:
|
|
44
|
+
try:
|
|
45
|
+
return v.to_bytes(w, "big", signed=True)
|
|
46
|
+
except OverflowError:
|
|
47
|
+
w += 1
|
|
48
|
+
|
|
49
|
+
return Expr.Bytes(int_to_min_tc(n)), pos + 1
|
|
50
|
+
except ValueError:
|
|
51
|
+
return Expr.Symbol(tok), pos + 1
|
|
52
52
|
|
|
53
53
|
def parse(tokens: List[str]) -> Tuple[Expr, List[str]]:
|
|
54
54
|
"""Parse tokens into an Expr and return (expr, remaining_tokens)."""
|
|
55
55
|
expr, next_pos = _parse_one(tokens, 0)
|
|
56
|
-
return expr, tokens[next_pos:]
|
|
56
|
+
return expr, tokens[next_pos:]
|
astreum/_node.py
CHANGED
|
@@ -3,10 +3,19 @@ from typing import Dict, Optional
|
|
|
3
3
|
import uuid
|
|
4
4
|
import threading
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
from ._storage.atom import Atom
|
|
7
|
+
from ._lispeum import Env, Expr, Meter, low_eval, parse, tokenize, ParseError
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"Node",
|
|
11
|
+
"Env",
|
|
12
|
+
"Expr",
|
|
13
|
+
"Meter",
|
|
14
|
+
"parse",
|
|
15
|
+
"tokenize",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
def bytes_touched(*vals: bytes) -> int:
|
|
10
19
|
"""For metering: how many bytes were manipulated (max of operands)."""
|
|
11
20
|
return max((len(v) for v in vals), default=1)
|
|
12
21
|
|
|
@@ -21,16 +30,16 @@ class Node:
|
|
|
21
30
|
self.machine_environments_lock = threading.RLock()
|
|
22
31
|
self.low_eval = low_eval
|
|
23
32
|
# Communication and Validation Setup (import lazily to avoid heavy deps during parsing tests)
|
|
24
|
-
try:
|
|
25
|
-
from astreum._communication import communication_setup # type: ignore
|
|
26
|
-
communication_setup(node=self, config=config)
|
|
27
|
-
except Exception:
|
|
28
|
-
pass
|
|
29
|
-
try:
|
|
30
|
-
from astreum._consensus import consensus_setup # type: ignore
|
|
31
|
-
consensus_setup(node=self, config=config)
|
|
32
|
-
except Exception:
|
|
33
|
-
pass
|
|
33
|
+
try:
|
|
34
|
+
from astreum._communication import communication_setup # type: ignore
|
|
35
|
+
communication_setup(node=self, config=config)
|
|
36
|
+
except Exception:
|
|
37
|
+
pass
|
|
38
|
+
try:
|
|
39
|
+
from astreum._consensus import consensus_setup # type: ignore
|
|
40
|
+
consensus_setup(node=self, config=config)
|
|
41
|
+
except Exception:
|
|
42
|
+
pass
|
|
34
43
|
|
|
35
44
|
|
|
36
45
|
|
|
@@ -75,7 +84,7 @@ class Node:
|
|
|
75
84
|
def _network_set(self, atom: Atom) -> None:
|
|
76
85
|
"""Advertise an atom to the closest known peer so they can fetch it from us."""
|
|
77
86
|
try:
|
|
78
|
-
from
|
|
87
|
+
from ._communication.message import Message, MessageTopic
|
|
79
88
|
except Exception:
|
|
80
89
|
return
|
|
81
90
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.47
|
|
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,5 +1,5 @@
|
|
|
1
1
|
astreum/__init__.py,sha256=9tzA27B_eG5wRF1SAWJIV7xTmCcR1QFc123b_cvFOa4,345
|
|
2
|
-
astreum/_node.py,sha256=
|
|
2
|
+
astreum/_node.py,sha256=f_4t0U0YyZhIrkFy6GNzWp_flMXDH8ES5GywUe56H7Q,3891
|
|
3
3
|
astreum/format.py,sha256=X4tG5GGPweNCE54bHYkLFiuLTbmpy5upO_s1Cef-MGA,2711
|
|
4
4
|
astreum/node.py,sha256=MmlK3jaANTMB3ZAxR8IaSc82OS9meJmVawYIVURADbg,39689
|
|
5
5
|
astreum/_communication/__init__.py,sha256=XJui0yOcfAur4HKt-8sSRlwB-MSU1rchkuOAY-nKDOE,207
|
|
@@ -29,7 +29,7 @@ astreum/_lispeum/expression.py,sha256=io8tbCer_1TJee77yRbcNI5q-DPFGa8xZiC80tGvRR
|
|
|
29
29
|
astreum/_lispeum/high_evaluation.py,sha256=7MwIeVZMPumYvKXn6Lkn-GrZhRNB6MjnUUWdiYT7Ei0,7952
|
|
30
30
|
astreum/_lispeum/low_evaluation.py,sha256=HgyCSAmL5K5SKq3Xw_BtbTZZUJbMg4-bVZW-A12glQ0,4373
|
|
31
31
|
astreum/_lispeum/meter.py,sha256=5q2PFW7_jmgKVM1-vwE4RRjMfPEthUA4iu1CwR-Axws,505
|
|
32
|
-
astreum/_lispeum/parser.py,sha256=
|
|
32
|
+
astreum/_lispeum/parser.py,sha256=rpxznlILbGruCS8wS_SQajYs7MlNPoMPbQ48XEjLeRo,2277
|
|
33
33
|
astreum/_lispeum/tokenizer.py,sha256=P68uIj4aPKzjuCJ85jfzRi67QztpuXIOC1vvLQueBI4,552
|
|
34
34
|
astreum/_storage/__init__.py,sha256=EmKZNAZmo3UVE3ekOOuckwFnBVjpa0Sy8Oxg72Lgdxc,53
|
|
35
35
|
astreum/_storage/atom.py,sha256=YFjvfMhniInch13iaKGpw4CCxxgyWonniryb-Rfse4A,4177
|
|
@@ -48,8 +48,8 @@ astreum/storage/object.py,sha256=knFlvw_tpcC4twSu1DGNpHX31wlANN8E5dgEqIfU--Q,204
|
|
|
48
48
|
astreum/storage/setup.py,sha256=1-9ztEFI_BvRDvAA0lAn4mFya8iq65THTArlj--M3Hg,626
|
|
49
49
|
astreum/utils/bytes.py,sha256=9QTWC2JCdwWLB5R2mPtmjPro0IUzE58DL3uEul4AheE,846
|
|
50
50
|
astreum/utils/integer.py,sha256=iQt-klWOYVghu_NOT341MmHbOle4FDT3by4PNKNXscg,736
|
|
51
|
-
astreum-0.2.
|
|
52
|
-
astreum-0.2.
|
|
53
|
-
astreum-0.2.
|
|
54
|
-
astreum-0.2.
|
|
55
|
-
astreum-0.2.
|
|
51
|
+
astreum-0.2.47.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
|
|
52
|
+
astreum-0.2.47.dist-info/METADATA,sha256=uTOobOKSzgiMyBbZTWOIOt7N4JpG448VpWrJNJq7OF0,6181
|
|
53
|
+
astreum-0.2.47.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
54
|
+
astreum-0.2.47.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
|
|
55
|
+
astreum-0.2.47.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|