astreum 0.2.41__py3-none-any.whl → 0.3.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.
- astreum/__init__.py +16 -7
- astreum/{_communication → communication}/__init__.py +3 -3
- astreum/communication/handlers/handshake.py +83 -0
- astreum/communication/handlers/ping.py +48 -0
- astreum/communication/handlers/storage_request.py +81 -0
- astreum/communication/models/__init__.py +0 -0
- astreum/{_communication → communication/models}/message.py +1 -0
- astreum/communication/models/peer.py +23 -0
- astreum/{_communication → communication/models}/route.py +45 -8
- astreum/{_communication → communication}/setup.py +46 -95
- astreum/communication/start.py +38 -0
- astreum/consensus/__init__.py +20 -0
- astreum/consensus/genesis.py +66 -0
- astreum/consensus/models/__init__.py +0 -0
- astreum/consensus/models/account.py +84 -0
- astreum/consensus/models/accounts.py +72 -0
- astreum/consensus/models/block.py +364 -0
- astreum/{_consensus → consensus/models}/chain.py +7 -7
- astreum/{_consensus → consensus/models}/fork.py +8 -8
- astreum/consensus/models/receipt.py +98 -0
- astreum/consensus/models/transaction.py +213 -0
- astreum/{_consensus → consensus}/setup.py +26 -11
- astreum/consensus/start.py +68 -0
- astreum/consensus/validator.py +95 -0
- astreum/{_consensus → consensus}/workers/discovery.py +20 -1
- astreum/consensus/workers/validation.py +291 -0
- astreum/{_consensus → consensus}/workers/verify.py +32 -3
- astreum/machine/__init__.py +20 -0
- astreum/machine/evaluations/__init__.py +0 -0
- astreum/machine/evaluations/high_evaluation.py +237 -0
- astreum/machine/evaluations/low_evaluation.py +281 -0
- astreum/machine/evaluations/script_evaluation.py +27 -0
- astreum/machine/models/__init__.py +0 -0
- astreum/machine/models/environment.py +31 -0
- astreum/machine/models/expression.py +218 -0
- astreum/{_lispeum → machine}/parser.py +26 -31
- astreum/machine/tokenizer.py +90 -0
- astreum/node.py +73 -781
- astreum/storage/__init__.py +7 -0
- astreum/storage/actions/get.py +69 -0
- astreum/storage/actions/set.py +132 -0
- astreum/storage/models/atom.py +107 -0
- astreum/{_storage/patricia.py → storage/models/trie.py} +236 -177
- astreum/storage/setup.py +44 -15
- astreum/utils/bytes.py +24 -0
- astreum/utils/integer.py +25 -0
- astreum/utils/logging.py +219 -0
- astreum-0.3.1.dist-info/METADATA +160 -0
- astreum-0.3.1.dist-info/RECORD +62 -0
- astreum/_communication/peer.py +0 -11
- astreum/_consensus/__init__.py +0 -20
- astreum/_consensus/account.py +0 -170
- astreum/_consensus/accounts.py +0 -67
- astreum/_consensus/block.py +0 -328
- astreum/_consensus/genesis.py +0 -141
- astreum/_consensus/receipt.py +0 -177
- astreum/_consensus/transaction.py +0 -192
- astreum/_consensus/workers/validation.py +0 -122
- astreum/_lispeum/__init__.py +0 -16
- astreum/_lispeum/environment.py +0 -13
- astreum/_lispeum/expression.py +0 -37
- astreum/_lispeum/high_evaluation.py +0 -177
- astreum/_lispeum/low_evaluation.py +0 -123
- astreum/_lispeum/tokenizer.py +0 -22
- astreum/_node.py +0 -58
- astreum/_storage/__init__.py +0 -5
- astreum/_storage/atom.py +0 -117
- astreum/format.py +0 -75
- astreum/models/block.py +0 -441
- astreum/models/merkle.py +0 -205
- astreum/models/patricia.py +0 -393
- astreum/storage/object.py +0 -68
- astreum-0.2.41.dist-info/METADATA +0 -146
- astreum-0.2.41.dist-info/RECORD +0 -53
- /astreum/{models → communication/handlers}/__init__.py +0 -0
- /astreum/{_communication → communication/models}/ping.py +0 -0
- /astreum/{_communication → communication}/util.py +0 -0
- /astreum/{_consensus → consensus}/workers/__init__.py +0 -0
- /astreum/{_lispeum → machine/models}/meter.py +0 -0
- {astreum-0.2.41.dist-info → astreum-0.3.1.dist-info}/WHEEL +0 -0
- {astreum-0.2.41.dist-info → astreum-0.3.1.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.2.41.dist-info → astreum-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def tokenize(source: str) -> List[str]:
|
|
5
|
+
tokens: List[str] = []
|
|
6
|
+
cur: List[str] = []
|
|
7
|
+
n = len(source)
|
|
8
|
+
i = 0
|
|
9
|
+
|
|
10
|
+
def flush_cur() -> None:
|
|
11
|
+
if cur:
|
|
12
|
+
tokens.append("".join(cur))
|
|
13
|
+
cur.clear()
|
|
14
|
+
|
|
15
|
+
def skip_line_comment(idx: int) -> int:
|
|
16
|
+
while idx < n and source[idx] != "\n":
|
|
17
|
+
idx += 1
|
|
18
|
+
return idx
|
|
19
|
+
|
|
20
|
+
def skip_ws_and_comments(idx: int) -> int:
|
|
21
|
+
while idx < n:
|
|
22
|
+
ch = source[idx]
|
|
23
|
+
if ch.isspace():
|
|
24
|
+
flush_cur()
|
|
25
|
+
idx += 1
|
|
26
|
+
continue
|
|
27
|
+
if ch == ";":
|
|
28
|
+
flush_cur()
|
|
29
|
+
idx = skip_line_comment(idx + 1)
|
|
30
|
+
continue
|
|
31
|
+
break
|
|
32
|
+
return idx
|
|
33
|
+
|
|
34
|
+
def skip_expression(idx: int) -> int:
|
|
35
|
+
idx = skip_ws_and_comments(idx)
|
|
36
|
+
if idx >= n:
|
|
37
|
+
return n
|
|
38
|
+
ch = source[idx]
|
|
39
|
+
if ch == "(":
|
|
40
|
+
depth = 0
|
|
41
|
+
while idx < n:
|
|
42
|
+
ch = source[idx]
|
|
43
|
+
if ch == "(":
|
|
44
|
+
depth += 1
|
|
45
|
+
idx += 1
|
|
46
|
+
continue
|
|
47
|
+
if ch == ")":
|
|
48
|
+
depth -= 1
|
|
49
|
+
idx += 1
|
|
50
|
+
if depth == 0:
|
|
51
|
+
break
|
|
52
|
+
continue
|
|
53
|
+
if ch == ";":
|
|
54
|
+
idx = skip_line_comment(idx + 1)
|
|
55
|
+
continue
|
|
56
|
+
if ch == "#" and idx + 1 < n and source[idx + 1] == ";":
|
|
57
|
+
idx = skip_expression(idx + 2)
|
|
58
|
+
continue
|
|
59
|
+
idx += 1
|
|
60
|
+
return idx
|
|
61
|
+
if ch == ")":
|
|
62
|
+
return idx + 1
|
|
63
|
+
while idx < n:
|
|
64
|
+
ch = source[idx]
|
|
65
|
+
if ch.isspace() or ch in ("(", ")", ";"):
|
|
66
|
+
break
|
|
67
|
+
if ch == "#" and idx + 1 < n and source[idx + 1] == ";":
|
|
68
|
+
break
|
|
69
|
+
idx += 1
|
|
70
|
+
return idx
|
|
71
|
+
|
|
72
|
+
while i < n:
|
|
73
|
+
i = skip_ws_and_comments(i)
|
|
74
|
+
if i >= n:
|
|
75
|
+
break
|
|
76
|
+
ch = source[i]
|
|
77
|
+
if ch == "#" and i + 1 < n and source[i + 1] == ";":
|
|
78
|
+
flush_cur()
|
|
79
|
+
i = skip_expression(i + 2)
|
|
80
|
+
continue
|
|
81
|
+
if ch in ("(", ")"):
|
|
82
|
+
flush_cur()
|
|
83
|
+
tokens.append(ch)
|
|
84
|
+
i += 1
|
|
85
|
+
continue
|
|
86
|
+
cur.append(ch)
|
|
87
|
+
i += 1
|
|
88
|
+
|
|
89
|
+
flush_cur()
|
|
90
|
+
return tokens
|