astreum 0.2.20__py3-none-any.whl → 0.2.22__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/models/accounts.py +34 -0
- {astreum-0.2.20.dist-info → astreum-0.2.22.dist-info}/METADATA +1 -1
- {astreum-0.2.20.dist-info → astreum-0.2.22.dist-info}/RECORD +6 -5
- {astreum-0.2.20.dist-info → astreum-0.2.22.dist-info}/WHEEL +0 -0
- {astreum-0.2.20.dist-info → astreum-0.2.22.dist-info}/licenses/LICENSE +0 -0
- {astreum-0.2.20.dist-info → astreum-0.2.22.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import Dict, Optional, Callable
|
|
3
|
+
from .patricia import PatriciaTrie
|
|
4
|
+
from .account import Account
|
|
5
|
+
|
|
6
|
+
class Accounts:
|
|
7
|
+
def __init__(
|
|
8
|
+
self,
|
|
9
|
+
root_hash: Optional[bytes] = None,
|
|
10
|
+
global_get_fn: Optional[Callable[[bytes], Optional[bytes]]] = None,
|
|
11
|
+
) -> None:
|
|
12
|
+
self._global_get_fn = global_get_fn
|
|
13
|
+
self._trie = PatriciaTrie(node_get=global_get_fn, root_hash=root_hash)
|
|
14
|
+
self._cache: Dict[bytes, Account] = {}
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def root_hash(self) -> Optional[bytes]:
|
|
18
|
+
return self._trie.root_hash
|
|
19
|
+
|
|
20
|
+
def get_account(self, address: bytes) -> Optional[Account]:
|
|
21
|
+
if address in self._cache:
|
|
22
|
+
return self._cache[address]
|
|
23
|
+
|
|
24
|
+
body_hash: Optional[bytes] = self._trie.get(address)
|
|
25
|
+
if body_hash is None:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
acc = Account(body_hash, get_node_fn=self._global_get_fn)
|
|
29
|
+
self._cache[address] = acc
|
|
30
|
+
return acc
|
|
31
|
+
|
|
32
|
+
def set_account(self, address: bytes, account: Account) -> None:
|
|
33
|
+
self._cache[address] = account
|
|
34
|
+
self._trie.put(address, account.body_hash())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: astreum
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.22
|
|
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
|
|
@@ -11,12 +11,13 @@ astreum/lispeum/parser.py,sha256=jQRzZYvBuSg8t_bxsbt1-WcHaR_LPveHNX7Qlxhaw-M,116
|
|
|
11
11
|
astreum/lispeum/tokenizer.py,sha256=J-I7MEd0r2ZoVqxvRPlu-Afe2ZdM0tKXXhf1R4SxYTo,1429
|
|
12
12
|
astreum/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
astreum/models/account.py,sha256=sHujGSwtV13rvOGJ5LZXuMrJ4F9XUdvyuWKz-zJ9lkE,2986
|
|
14
|
+
astreum/models/accounts.py,sha256=aFSEWlq6zRf65-KGAdNGqEJyNVY3fpKhx8y1vU6sgSc,1164
|
|
14
15
|
astreum/models/block.py,sha256=YIY3qLneFM7OooY29khLDEs3NIEA7y8VhlXitflkxTo,4564
|
|
15
16
|
astreum/models/merkle.py,sha256=merV3rx2iRfzvglV6gNusrJf7OMbcVV854T-DUWCC64,6733
|
|
16
17
|
astreum/models/patricia.py,sha256=ohmXrcaz7Ae561tyC4u4iPOkQPkKr8N0IWJek4upFIg,13392
|
|
17
18
|
astreum/models/transaction.py,sha256=yBarvRK2ybMAHHEQPZpubGO7gms4U9k093xQGNQHQ4Q,3043
|
|
18
|
-
astreum-0.2.
|
|
19
|
-
astreum-0.2.
|
|
20
|
-
astreum-0.2.
|
|
21
|
-
astreum-0.2.
|
|
22
|
-
astreum-0.2.
|
|
19
|
+
astreum-0.2.22.dist-info/licenses/LICENSE,sha256=gYBvRDP-cPLmTyJhvZ346QkrYW_eleke4Z2Yyyu43eQ,1089
|
|
20
|
+
astreum-0.2.22.dist-info/METADATA,sha256=sjq4dOe1ozAw17evuGntKyahKDMfqQwcrcpp_b6QhK4,5478
|
|
21
|
+
astreum-0.2.22.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
22
|
+
astreum-0.2.22.dist-info/top_level.txt,sha256=1EG1GmkOk3NPmUA98FZNdKouhRyget-KiFiMk0i2Uz0,8
|
|
23
|
+
astreum-0.2.22.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|