def perform_vlob_read(self, intent):
async with self.connection.acquire() as conn:
async with conn.cursor() as cur:
if intent.version:
await cur.execute("SELECT * FROM vlobs WHERE "
"id=%s AND version=%s;", (intent.id, intent.version))
else:
await cur.execute("SELECT * FROM vlobs WHERE "
"id=%s ORDER BY version DESC;", (intent.id, ))
ret = await cur.fetchone()
if not ret:
raise VlobNotFound('Vlob not found.')
_, version, rts, wts, blob = ret
if rts != intent.trust_seed:
raise TrustSeedError('Invalid read trust seed.')
return VlobAtom(id=intent.id, version=version, read_trust_seed=rts,
write_trust_seed=wts, blob=bytes(blob))
评论列表
文章目录