astreum 0.2.20__tar.gz → 0.2.22__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.

Files changed (29) hide show
  1. {astreum-0.2.20/src/astreum.egg-info → astreum-0.2.22}/PKG-INFO +1 -1
  2. {astreum-0.2.20 → astreum-0.2.22}/pyproject.toml +1 -1
  3. astreum-0.2.22/src/astreum/models/accounts.py +34 -0
  4. {astreum-0.2.20 → astreum-0.2.22/src/astreum.egg-info}/PKG-INFO +1 -1
  5. {astreum-0.2.20 → astreum-0.2.22}/src/astreum.egg-info/SOURCES.txt +1 -0
  6. {astreum-0.2.20 → astreum-0.2.22}/LICENSE +0 -0
  7. {astreum-0.2.20 → astreum-0.2.22}/README.md +0 -0
  8. {astreum-0.2.20 → astreum-0.2.22}/setup.cfg +0 -0
  9. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/__init__.py +0 -0
  10. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/crypto/__init__.py +0 -0
  11. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/crypto/ed25519.py +0 -0
  12. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/crypto/quadratic_form.py +0 -0
  13. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/crypto/wesolowski.py +0 -0
  14. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/crypto/x25519.py +0 -0
  15. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/format.py +0 -0
  16. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/lispeum/__init__.py +0 -0
  17. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/lispeum/parser.py +0 -0
  18. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/lispeum/tokenizer.py +0 -0
  19. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/__init__.py +0 -0
  20. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/account.py +0 -0
  21. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/block.py +0 -0
  22. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/merkle.py +0 -0
  23. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/patricia.py +0 -0
  24. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/models/transaction.py +0 -0
  25. {astreum-0.2.20 → astreum-0.2.22}/src/astreum/node.py +0 -0
  26. {astreum-0.2.20 → astreum-0.2.22}/src/astreum.egg-info/dependency_links.txt +0 -0
  27. {astreum-0.2.20 → astreum-0.2.22}/src/astreum.egg-info/requires.txt +0 -0
  28. {astreum-0.2.20 → astreum-0.2.22}/src/astreum.egg-info/top_level.txt +0 -0
  29. {astreum-0.2.20 → astreum-0.2.22}/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.20
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "astreum"
3
- version = "0.2.20"
3
+ version = "0.2.22"
4
4
  authors = [
5
5
  { name="Roy R. O. Okello", email="roy@stelar.xyz" },
6
6
  ]
@@ -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.20
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
@@ -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