dev@locazia: ui fixes

This commit is contained in:
user 2024-03-08 19:43:52 +03:00
parent 606ef553bc
commit b4b7a878f4
2 changed files with 12 additions and 2 deletions

View File

@ -28,6 +28,16 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
make_log("Indexer", "Service running", level="debug")
with db_session() as session:
content_without_cid = session.query(StoredContent).filter(
StoredContent.content_id == None
)
for target_content in content_without_cid:
target_cid = target_content.cid.serialize_v2()
make_log("Indexer", f"Content without CID: {target_content.hash}, setting CID: {target_cid}", level="debug")
target_content.content_id = target_cid
session.commit()
last_known_index = session.query(StoredContent).filter(
StoredContent.type == "onchain/content"
).order_by(StoredContent.onchain_index.desc()).first()

View File

@ -38,7 +38,7 @@ class ContentId:
def safe_onchain_index(self):
return self.onchain_index if (not (self.onchain_index is None) and self.onchain_index >= 0) else None
def serialize_v2(self) -> str:
def serialize_v2(self, include_accept_type=False) -> str:
cid_bin = (
(2).to_bytes(1, 'big') # cid version
+ self.content_hash
@ -47,7 +47,7 @@ class ContentId:
oi_bin_hex = hex(self.safe_onchain_index)[2:]
oi_bin_len = math.ceil(len(oi_bin_hex) / 2)
cid_bin += b'\xb0' + oi_bin_len.to_bytes(1, 'big') + bytes.fromhex(oi_bin_hex)
if self.accept_type:
if self.accept_type and include_accept_type:
at_bin_len = len(self.accept_type.encode())
at_bin = string_to_bytes_fixed_size(self.accept_type, at_bin_len)
cid_bin += (