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.
Files changed (82) hide show
  1. astreum/__init__.py +16 -7
  2. astreum/{_communication → communication}/__init__.py +3 -3
  3. astreum/communication/handlers/handshake.py +83 -0
  4. astreum/communication/handlers/ping.py +48 -0
  5. astreum/communication/handlers/storage_request.py +81 -0
  6. astreum/communication/models/__init__.py +0 -0
  7. astreum/{_communication → communication/models}/message.py +1 -0
  8. astreum/communication/models/peer.py +23 -0
  9. astreum/{_communication → communication/models}/route.py +45 -8
  10. astreum/{_communication → communication}/setup.py +46 -95
  11. astreum/communication/start.py +38 -0
  12. astreum/consensus/__init__.py +20 -0
  13. astreum/consensus/genesis.py +66 -0
  14. astreum/consensus/models/__init__.py +0 -0
  15. astreum/consensus/models/account.py +84 -0
  16. astreum/consensus/models/accounts.py +72 -0
  17. astreum/consensus/models/block.py +364 -0
  18. astreum/{_consensus → consensus/models}/chain.py +7 -7
  19. astreum/{_consensus → consensus/models}/fork.py +8 -8
  20. astreum/consensus/models/receipt.py +98 -0
  21. astreum/consensus/models/transaction.py +213 -0
  22. astreum/{_consensus → consensus}/setup.py +26 -11
  23. astreum/consensus/start.py +68 -0
  24. astreum/consensus/validator.py +95 -0
  25. astreum/{_consensus → consensus}/workers/discovery.py +20 -1
  26. astreum/consensus/workers/validation.py +291 -0
  27. astreum/{_consensus → consensus}/workers/verify.py +32 -3
  28. astreum/machine/__init__.py +20 -0
  29. astreum/machine/evaluations/__init__.py +0 -0
  30. astreum/machine/evaluations/high_evaluation.py +237 -0
  31. astreum/machine/evaluations/low_evaluation.py +281 -0
  32. astreum/machine/evaluations/script_evaluation.py +27 -0
  33. astreum/machine/models/__init__.py +0 -0
  34. astreum/machine/models/environment.py +31 -0
  35. astreum/machine/models/expression.py +218 -0
  36. astreum/{_lispeum → machine}/parser.py +26 -31
  37. astreum/machine/tokenizer.py +90 -0
  38. astreum/node.py +73 -781
  39. astreum/storage/__init__.py +7 -0
  40. astreum/storage/actions/get.py +69 -0
  41. astreum/storage/actions/set.py +132 -0
  42. astreum/storage/models/atom.py +107 -0
  43. astreum/{_storage/patricia.py → storage/models/trie.py} +236 -177
  44. astreum/storage/setup.py +44 -15
  45. astreum/utils/bytes.py +24 -0
  46. astreum/utils/integer.py +25 -0
  47. astreum/utils/logging.py +219 -0
  48. astreum-0.3.1.dist-info/METADATA +160 -0
  49. astreum-0.3.1.dist-info/RECORD +62 -0
  50. astreum/_communication/peer.py +0 -11
  51. astreum/_consensus/__init__.py +0 -20
  52. astreum/_consensus/account.py +0 -170
  53. astreum/_consensus/accounts.py +0 -67
  54. astreum/_consensus/block.py +0 -328
  55. astreum/_consensus/genesis.py +0 -141
  56. astreum/_consensus/receipt.py +0 -177
  57. astreum/_consensus/transaction.py +0 -192
  58. astreum/_consensus/workers/validation.py +0 -122
  59. astreum/_lispeum/__init__.py +0 -16
  60. astreum/_lispeum/environment.py +0 -13
  61. astreum/_lispeum/expression.py +0 -37
  62. astreum/_lispeum/high_evaluation.py +0 -177
  63. astreum/_lispeum/low_evaluation.py +0 -123
  64. astreum/_lispeum/tokenizer.py +0 -22
  65. astreum/_node.py +0 -58
  66. astreum/_storage/__init__.py +0 -5
  67. astreum/_storage/atom.py +0 -117
  68. astreum/format.py +0 -75
  69. astreum/models/block.py +0 -441
  70. astreum/models/merkle.py +0 -205
  71. astreum/models/patricia.py +0 -393
  72. astreum/storage/object.py +0 -68
  73. astreum-0.2.41.dist-info/METADATA +0 -146
  74. astreum-0.2.41.dist-info/RECORD +0 -53
  75. /astreum/{models → communication/handlers}/__init__.py +0 -0
  76. /astreum/{_communication → communication/models}/ping.py +0 -0
  77. /astreum/{_communication → communication}/util.py +0 -0
  78. /astreum/{_consensus → consensus}/workers/__init__.py +0 -0
  79. /astreum/{_lispeum → machine/models}/meter.py +0 -0
  80. {astreum-0.2.41.dist-info → astreum-0.3.1.dist-info}/WHEEL +0 -0
  81. {astreum-0.2.41.dist-info → astreum-0.3.1.dist-info}/licenses/LICENSE +0 -0
  82. {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