This commit is contained in:
Kyle Altendorf 2022-01-21 21:17:15 -05:00
parent dcb1c1569b
commit 863458f615
No known key found for this signature in database
GPG Key ID: 5715D880FF005192
3 changed files with 9 additions and 9 deletions

View File

@ -84,7 +84,7 @@ class DataLayer:
self,
tree_id: bytes32,
changelist: List[Dict[str, Any]],
) -> Optional[TransactionRecord]:
) -> TransactionRecord:
for change in changelist:
if change["action"] == "insert":
key = change["key"]
@ -106,11 +106,11 @@ class DataLayer:
node_hash = root.node_hash
else:
node_hash = bytes32([0] * 32) # todo change
res = await self.wallet_rpc.dl_update_root(tree_id, node_hash)
assert res
transaction_record = await self.wallet_rpc.dl_update_root(tree_id, node_hash)
assert transaction_record
# todo register callback to change status in data store
# await self.data_store.change_root_status(root, Status.COMMITTED)
return res
return transaction_record
async def get_value(self, store_id: bytes32, key: bytes) -> Optional[bytes]:
res = await self.data_store.get_node_by_key(tree_id=store_id, key=key)

View File

@ -119,8 +119,8 @@ class DataLayerRpcApi:
if self.service is None:
raise Exception("Data layer not created")
changelist = [{"action": "insert", "key": key.hex(), "value": value.hex()}]
await self.service.batch_update(store_id, changelist)
return {"tx_id": "id"}
transaction_record = await self.service.batch_update(store_id, changelist)
return {"tx_id": transaction_record.name}
async def delete_key(self, request: Dict[str, Any]) -> Dict[str, Any]:
"""
@ -133,8 +133,8 @@ class DataLayerRpcApi:
if self.service is None:
raise Exception("Data layer not created")
changelist = [{"action": "delete", "key": key.hex()}]
txs = await self.service.batch_update(store_id, changelist)
return {"tx_ids": txs}
transaction_record = await self.service.batch_update(store_id, changelist)
return {"tx_id": transaction_record.name}
async def get_root(self, request: Dict[str, Any]) -> Dict[str, Any]:
"""

View File

@ -143,7 +143,7 @@ async def setup_data_layer(local_bt):
# db_path = local_bt.root_path / f"{db_name}"
# if db_path.exists():
# db_path.unlink()
config = local_bt.config["data_layer"]
# config = local_bt.config["data_layer"]
# config["database_path"] = db_name
# if introducer_port is not None:
# config["introducer_peer"]["host"] = self_hostname