remove DataStore tree table

This commit is contained in:
Kyle Altendorf
2021-10-15 10:59:37 -04:00
parent 4d55b9f8b8
commit a0cdf87545
2 changed files with 2 additions and 8 deletions
+2 -5
View File
@@ -49,7 +49,6 @@ class DataStore:
await self.db.execute("PRAGMA foreign_keys=ON")
async with self.db_wrapper.locked_transaction():
await self.db.execute("CREATE TABLE IF NOT EXISTS tree(id TEXT PRIMARY KEY NOT NULL)")
# TODO: figure out the use of the generation
await self.db.execute(
"CREATE TABLE IF NOT EXISTS node("
@@ -70,7 +69,6 @@ class DataStore:
" generation INTEGER NOT NULL,"
" node_hash TEXT,"
" PRIMARY KEY(tree_id, generation),"
" FOREIGN KEY(tree_id) REFERENCES tree(id),"
" FOREIGN KEY(node_hash) REFERENCES node(hash)"
")"
)
@@ -222,7 +220,6 @@ class DataStore:
async def create_tree(self, tree_id: bytes32, *, lock: bool = True) -> bool:
async with self.db_wrapper.locked_transaction(lock=lock):
await self.db.execute("INSERT INTO tree(id) VALUES(:id)", {"id": tree_id.hex()})
await self._insert_root(tree_id=tree_id, node_hash=None)
return True
@@ -235,9 +232,9 @@ class DataStore:
async def get_tree_ids(self, *, lock: bool = True) -> Set[bytes32]:
async with self.db_wrapper.locked_transaction(lock=lock):
cursor = await self.db.execute("SELECT id FROM tree")
cursor = await self.db.execute("SELECT DISTINCT tree_id FROM root")
tree_ids = {bytes32(hexstr_to_bytes(row["id"])) async for row in cursor}
tree_ids = {bytes32(hexstr_to_bytes(row["tree_id"])) async for row in cursor}
return tree_ids
-3
View File
@@ -75,7 +75,6 @@ async def data_store_fixture(raw_data_store: DataStore, tree_id: bytes32) -> Asy
table_columns: Dict[str, List[str]] = {
"tree": ["id"],
"node": ["hash", "node_type", "left", "right", "key", "value"],
"root": ["tree_id", "generation", "node_hash"],
}
@@ -634,7 +633,6 @@ async def test_check_roots_are_incrementing_missing_zero(raw_data_store: DataSto
tree_id = hexstr_to_bytes("c954ab71ffaf5b0f129b04b35fdc7c84541f4375167e730e2646bfcfdb7cf2cd")
async with raw_data_store.db_wrapper.locked_transaction():
await raw_data_store.db.execute("INSERT INTO tree(id) VALUES(:id)", {"id": tree_id.hex()})
for generation in range(1, 5):
await raw_data_store.db.execute(
"INSERT INTO root(tree_id, generation, node_hash) VALUES(:tree_id, :generation, :node_hash)",
@@ -653,7 +651,6 @@ async def test_check_roots_are_incrementing_gap(raw_data_store: DataStore) -> No
tree_id = hexstr_to_bytes("c954ab71ffaf5b0f129b04b35fdc7c84541f4375167e730e2646bfcfdb7cf2cd")
async with raw_data_store.db_wrapper.locked_transaction():
await raw_data_store.db.execute("INSERT INTO tree(id) VALUES(:id)", {"id": tree_id.hex()})
for generation in range(5):
await raw_data_store.db.execute(
"INSERT INTO root(tree_id, generation, node_hash) VALUES(:tree_id, :generation, :node_hash)",