astreum 0.2.20__tar.gz → 0.2.21__tar.gz
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-0.2.20/src/astreum.egg-info → astreum-0.2.21}/PKG-INFO +1 -1
- {astreum-0.2.20 → astreum-0.2.21}/pyproject.toml +1 -1
- astreum-0.2.21/src/astreum/models/accounts.py +80 -0
- {astreum-0.2.20 → astreum-0.2.21/src/astreum.egg-info}/PKG-INFO +1 -1
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum.egg-info/SOURCES.txt +1 -0
- {astreum-0.2.20 → astreum-0.2.21}/LICENSE +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/README.md +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/setup.cfg +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/__init__.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/crypto/__init__.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/crypto/ed25519.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/crypto/quadratic_form.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/crypto/wesolowski.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/crypto/x25519.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/format.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/lispeum/__init__.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/lispeum/parser.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/lispeum/tokenizer.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/__init__.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/account.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/block.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/merkle.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/patricia.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/models/transaction.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum/node.py +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum.egg-info/dependency_links.txt +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum.egg-info/requires.txt +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/src/astreum.egg-info/top_level.txt +0 -0
- {astreum-0.2.20 → astreum-0.2.21}/tests/test_node_machine.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.21
|
|
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
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Account‐state management built on a PatriciaTrie.
|
|
2
|
+
|
|
3
|
+
Only the *initial skeleton* is provided here per current request:
|
|
4
|
+
• __init__: wrap an existing trie root (or start empty).
|
|
5
|
+
• get_account: look up an Account object, using a cache so multiple
|
|
6
|
+
balance/nonce updates in one block operate on the same instance.
|
|
7
|
+
|
|
8
|
+
Additional mutation helpers (set_account, change_balance, etc.) will be
|
|
9
|
+
added next, once confirmed.
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from typing import Dict, Optional, Callable
|
|
14
|
+
|
|
15
|
+
from .patricia import PatriciaTrie
|
|
16
|
+
from .account import Account
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Accounts:
|
|
20
|
+
"""Light wrapper around a PatriciaTrie (address → body_hash) plus
|
|
21
|
+
an in‑memory cache of Account objects currently being worked on.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
# ------------------------------------------------------------
|
|
25
|
+
# construction
|
|
26
|
+
# ------------------------------------------------------------
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
root_hash: Optional[bytes] = None,
|
|
30
|
+
*,
|
|
31
|
+
get_node_fn: Optional[Callable[[bytes], Optional[bytes]]] = None,
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Wrap an existing state trie *or* start empty (root_hash=None).
|
|
34
|
+
|
|
35
|
+
`get_node_fn` (optional) is a callback that retrieves raw node bytes
|
|
36
|
+
when the underlying PatriciaTrie encounters an unknown hash – useful
|
|
37
|
+
for disk or network-backed light clients.
|
|
38
|
+
"""
|
|
39
|
+
self._remote_get = get_node_fn
|
|
40
|
+
# Instantiate the trie; we pass the external fetcher straight in.
|
|
41
|
+
# PatriciaTrie is expected to accept `node_get` and `root_hash`.
|
|
42
|
+
self._trie = PatriciaTrie(node_get=get_node_fn, root_hash=root_hash)
|
|
43
|
+
|
|
44
|
+
# Working‑set cache: address → Account instance
|
|
45
|
+
self._cache: Dict[bytes, Account] = {}
|
|
46
|
+
|
|
47
|
+
# ------------------------------------------------------------
|
|
48
|
+
# public introspection
|
|
49
|
+
# ------------------------------------------------------------
|
|
50
|
+
@property
|
|
51
|
+
def root_hash(self) -> Optional[bytes]:
|
|
52
|
+
"""Current trie root (updates automatically after puts)."""
|
|
53
|
+
return self._trie.root_hash
|
|
54
|
+
|
|
55
|
+
# ------------------------------------------------------------
|
|
56
|
+
# account access – read‑only for now
|
|
57
|
+
# ------------------------------------------------------------
|
|
58
|
+
def get_account(self, address: bytes) -> Optional[Account]:
|
|
59
|
+
"""Return an *Account* for `address`, or *None* if it doesn't exist.
|
|
60
|
+
|
|
61
|
+
• First check the in‑memory cache (so repeat reads/updates reuse the
|
|
62
|
+
same object).
|
|
63
|
+
• Otherwise look up `body_hash` in the PatriciaTrie.
|
|
64
|
+
• If found, create a lightweight `Account` wrapper, cache it, and
|
|
65
|
+
return it. The Account is initialised with the same external
|
|
66
|
+
node‑fetcher so its own Merkle lookups can go remote if needed.
|
|
67
|
+
"""
|
|
68
|
+
# cache hit → hot path
|
|
69
|
+
if address in self._cache:
|
|
70
|
+
return self._cache[address]
|
|
71
|
+
|
|
72
|
+
# trie lookup (raw body_hash)
|
|
73
|
+
body_hash: Optional[bytes] = self._trie.get(address)
|
|
74
|
+
if body_hash is None:
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
# wrap in Account and cache
|
|
78
|
+
acc = Account(body_hash, get_node_fn=self._remote_get)
|
|
79
|
+
self._cache[address] = acc
|
|
80
|
+
return acc
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.21
|
|
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
|
|
@@ -19,6 +19,7 @@ src/astreum/lispeum/parser.py
|
|
|
19
19
|
src/astreum/lispeum/tokenizer.py
|
|
20
20
|
src/astreum/models/__init__.py
|
|
21
21
|
src/astreum/models/account.py
|
|
22
|
+
src/astreum/models/accounts.py
|
|
22
23
|
src/astreum/models/block.py
|
|
23
24
|
src/astreum/models/merkle.py
|
|
24
25
|
src/astreum/models/patricia.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|