async def persist_sub_epoch_challenge_segments( self, sub_epoch_summary_height: uint32, segments: List[SubEpochChallengeSegment]) -> None: cursor_1 = await self.db.execute( "INSERT OR REPLACE INTO sub_epoch_segments_v2 VALUES(?, ?)", (sub_epoch_summary_height, bytes(SubEpochSegments(segments))), ) await cursor_1.close()
async def persist_sub_epoch_challenge_segments( self, ses_block_hash: bytes32, segments: List[SubEpochChallengeSegment] ) -> None: async with self.db_wrapper.lock: await self.db.execute( "INSERT OR REPLACE INTO sub_epoch_segments_v3 VALUES(?, ?)", (self.maybe_to_hex(ses_block_hash), bytes(SubEpochSegments(segments))), ) await self.db.commit()
async def get_sub_epoch_challenge_segments( self, sub_epoch_summary_height: uint32, ) -> Optional[List[SubEpochChallengeSegment]]: cursor = await self.db.execute( "SELECT challenge_segments from sub_epoch_segments_v2 WHERE ses_height=?", (sub_epoch_summary_height, )) row = await cursor.fetchone() await cursor.close() if row is not None: return SubEpochSegments.from_bytes(row[0]).challenge_segments return None
async def get_sub_epoch_challenge_segments( self, ses_block_hash: bytes32, ) -> Optional[List[SubEpochChallengeSegment]]: cursor = await self.db.execute( "SELECT challenge_segments from sub_epoch_segments_v3 WHERE ses_block_hash=?", (ses_block_hash.hex(),) ) row = await cursor.fetchone() await cursor.close() if row is not None: return SubEpochSegments.from_bytes(row[0]).challenge_segments return None
async def get_sub_epoch_challenge_segments( self, ses_block_hash: bytes32, ) -> Optional[List[SubEpochChallengeSegment]]: cached = self.ses_challenge_cache.get(ses_block_hash) if cached is not None: return cached async with self.db.execute( "SELECT challenge_segments from sub_epoch_segments_v3 WHERE ses_block_hash=?", (self.maybe_to_hex(ses_block_hash),), ) as cursor: row = await cursor.fetchone() if row is not None: challenge_segments = SubEpochSegments.from_bytes(row[0]).challenge_segments self.ses_challenge_cache.put(ses_block_hash, challenge_segments) return challenge_segments return None
async def persist_sub_epoch_challenge_segments( self, sub_epoch_summary_height: uint32, segments: List[SubEpochChallengeSegment] ): self._sub_epoch_segments[sub_epoch_summary_height] = SubEpochSegments(segments)
async def persist_sub_epoch_challenge_segments( self, sub_epoch_summary_hash: bytes32, segments: List[SubEpochChallengeSegment]): self._sub_epoch_segments[sub_epoch_summary_hash] = SubEpochSegments( segments)