astreum 0.1.10__tar.gz → 0.1.12__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 (42) hide show
  1. {astreum-0.1.10/src/astreum.egg-info → astreum-0.1.12}/PKG-INFO +1 -1
  2. {astreum-0.1.10 → astreum-0.1.12}/pyproject.toml +1 -1
  3. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/__init__.py +5 -4
  4. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/models.py +30 -5
  5. {astreum-0.1.10 → astreum-0.1.12/src/astreum.egg-info}/PKG-INFO +1 -1
  6. {astreum-0.1.10 → astreum-0.1.12}/LICENSE +0 -0
  7. {astreum-0.1.10 → astreum-0.1.12}/README.md +0 -0
  8. {astreum-0.1.10 → astreum-0.1.12}/setup.cfg +0 -0
  9. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/__init__.py +0 -0
  10. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/__init__.py +0 -0
  11. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/expression.py +0 -0
  12. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/parser.py +0 -0
  13. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/__init__.py +0 -0
  14. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/definition.py +0 -0
  15. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/__init__.py +0 -0
  16. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/all.py +0 -0
  17. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/any.py +0 -0
  18. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/fold.py +0 -0
  19. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/get.py +0 -0
  20. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/insert.py +0 -0
  21. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/map.py +0 -0
  22. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/position.py +0 -0
  23. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/list/remove.py +0 -0
  24. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/number/__init__.py +0 -0
  25. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/special/number/addition.py +0 -0
  26. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/storage.py +0 -0
  27. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/lispeum/tokenizer.py +0 -0
  28. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/machine/__init__.py +0 -0
  29. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/machine/environment.py +0 -0
  30. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/machine/error.py +0 -0
  31. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/__init__.py +0 -0
  32. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/bucket.py +0 -0
  33. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/envelope.py +0 -0
  34. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/message.py +0 -0
  35. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/peer.py +0 -0
  36. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/node/relay/route.py +0 -0
  37. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/utils/__init__.py +0 -0
  38. {astreum-0.1.10 → astreum-0.1.12}/src/astreum/utils/bytes_format.py +0 -0
  39. {astreum-0.1.10 → astreum-0.1.12}/src/astreum.egg-info/SOURCES.txt +0 -0
  40. {astreum-0.1.10 → astreum-0.1.12}/src/astreum.egg-info/dependency_links.txt +0 -0
  41. {astreum-0.1.10 → astreum-0.1.12}/src/astreum.egg-info/requires.txt +0 -0
  42. {astreum-0.1.10 → astreum-0.1.12}/src/astreum.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: astreum
3
- Version: 0.1.10
3
+ Version: 0.1.12
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.1.10"
3
+ version = "0.1.12"
4
4
  authors = [
5
5
  { name="Roy R. O. Okello", email="roy@stelar.xyz" },
6
6
  ]
@@ -13,16 +13,17 @@ from astreum.lispeum.storage import store_expr, get_expr_from_storage
13
13
 
14
14
  class Node:
15
15
  def __init__(self, config: dict):
16
- self.config = config
17
- self.relay = Relay(config)
16
+ # Ensure config is a dictionary, but allow it to be None
17
+ self.config = config if config is not None else {}
18
+ self.relay = Relay(self.config)
18
19
  # Get the node_id from relay instead of generating our own
19
20
  self.node_id = self.relay.node_id
20
- self.storage = Storage(config)
21
+ self.storage = Storage(self.config)
21
22
  self.storage.node = self # Set the storage node reference to self
22
23
 
23
24
  # Latest block of the chain this node is following
24
25
  self.latest_block = None
25
- self.followed_chain_id = config.get('followed_chain_id', None)
26
+ self.followed_chain_id = self.config.get('followed_chain_id', None)
26
27
 
27
28
  # Initialize machine
28
29
  self.machine = AstreumMachine(node=self)
@@ -15,8 +15,21 @@ class Storage:
15
15
  def __init__(self, config: dict):
16
16
  self.max_space = config.get('max_storage_space', 1024 * 1024 * 1024) # Default 1GB
17
17
  self.current_space = 0
18
- self.storage_path = Path(config.get('storage_path', 'storage'))
19
- self.storage_path.mkdir(parents=True, exist_ok=True)
18
+
19
+ # Check if storage_path is provided in config
20
+ storage_path = config.get('storage_path')
21
+ self.use_memory_storage = storage_path is None
22
+
23
+ # Initialize in-memory storage if no path provided
24
+ self.memory_storage = {} if self.use_memory_storage else None
25
+
26
+ # Only create storage path if not using memory storage
27
+ if not self.use_memory_storage:
28
+ self.storage_path = Path(storage_path)
29
+ self.storage_path.mkdir(parents=True, exist_ok=True)
30
+ # Calculate current space usage
31
+ self.current_space = sum(f.stat().st_size for f in self.storage_path.glob('*') if f.is_file())
32
+
20
33
  self.max_object_recursion = config.get('max_object_recursion', 50)
21
34
  self.network_request_timeout = config.get('network_request_timeout', 5.0) # Default 5 second timeout
22
35
  self.node = None # Will be set by the Node after initialization
@@ -24,9 +37,6 @@ class Storage:
24
37
  # In-progress requests tracking
25
38
  self.pending_requests = {} # hash -> (start_time, event)
26
39
  self.request_lock = threading.Lock()
27
-
28
- # Calculate current space usage
29
- self.current_space = sum(f.stat().st_size for f in self.storage_path.glob('*') if f.is_file())
30
40
 
31
41
  def put(self, data_hash: bytes, data: bytes) -> bool:
32
42
  """Store data with its hash. Returns True if successful, False if space limit exceeded."""
@@ -34,6 +44,14 @@ class Storage:
34
44
  if self.current_space + data_size > self.max_space:
35
45
  return False
36
46
 
47
+ # If using memory storage, store in dictionary
48
+ if self.use_memory_storage:
49
+ if data_hash not in self.memory_storage:
50
+ self.memory_storage[data_hash] = data
51
+ self.current_space += data_size
52
+ return True
53
+
54
+ # Otherwise use file storage
37
55
  file_path = self.storage_path / data_hash.hex()
38
56
 
39
57
  # Don't store if already exists
@@ -54,6 +72,11 @@ class Storage:
54
72
 
55
73
  def _local_get(self, data_hash: bytes) -> Optional[bytes]:
56
74
  """Get data from local storage only, no network requests."""
75
+ # If using memory storage, get from dictionary
76
+ if self.use_memory_storage:
77
+ return self.memory_storage.get(data_hash)
78
+
79
+ # Otherwise use file storage
57
80
  file_path = self.storage_path / data_hash.hex()
58
81
  if file_path.exists():
59
82
  return file_path.read_bytes()
@@ -144,6 +167,8 @@ class Storage:
144
167
 
145
168
  def contains(self, data_hash: bytes) -> bool:
146
169
  """Check if data exists in storage."""
170
+ if self.use_memory_storage:
171
+ return data_hash in self.memory_storage
147
172
  return (self.storage_path / data_hash.hex()).exists()
148
173
 
149
174
  def get_recursive(self, root_hash: bytes, max_depth: Optional[int] = None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: astreum
3
- Version: 0.1.10
3
+ Version: 0.1.12
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
File without changes
File without changes
File without changes