Skip to content

Commit 9f514ab

Browse files
committed
inline coinstore bool
1 parent d463758 commit 9f514ab

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

chia/full_node/coin_store.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]:
181181
if row is not None:
182182
coin = self.row_to_coin(row)
183183
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
184-
coinbase = False if row[2] == 0 else True
185-
return CoinRecord(coin, row[0], spent_index, coinbase, row[6])
184+
return CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6])
186185
return None
187186

188187
async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]:
@@ -208,8 +207,7 @@ async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]
208207
for row in await cursor.fetchall():
209208
coin = self.row_to_coin(row)
210209
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
211-
coinbase = False if row[2] == 0 else True
212-
record = CoinRecord(coin, row[0], spent_index, coinbase, row[6])
210+
record = CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6])
213211
coins.append(record)
214212

215213
return coins
@@ -226,8 +224,7 @@ async def get_coins_added_at_height(self, height: uint32) -> list[CoinRecord]:
226224
for row in rows:
227225
coin = self.row_to_coin(row)
228226
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
229-
coinbase = False if row[2] == 0 else True
230-
coins.append(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
227+
coins.append(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
231228
return coins
232229

233230
async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
@@ -244,8 +241,7 @@ async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
244241
for row in await cursor.fetchall():
245242
if row[1] > 0:
246243
coin = self.row_to_coin(row)
247-
coinbase = False if row[2] == 0 else True
248-
coin_record = CoinRecord(coin, row[0], row[1], coinbase, row[6])
244+
coin_record = CoinRecord(coin, row[0], row[1], row[2] != 0, row[6])
249245
coins.append(coin_record)
250246
return coins
251247

@@ -270,8 +266,7 @@ async def get_coin_records_by_puzzle_hash(
270266
for row in await cursor.fetchall():
271267
coin = self.row_to_coin(row)
272268
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
273-
coinbase = False if row[2] == 0 else True
274-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
269+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
275270
return list(coins)
276271

277272
async def get_coin_records_by_puzzle_hashes(
@@ -300,8 +295,7 @@ async def get_coin_records_by_puzzle_hashes(
300295
for row in await cursor.fetchall():
301296
coin = self.row_to_coin(row)
302297
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
303-
coinbase = False if row[2] == 0 else True
304-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
298+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
305299
return list(coins)
306300

307301
async def get_coin_records_by_names(
@@ -328,8 +322,7 @@ async def get_coin_records_by_names(
328322
for row in await cursor.fetchall():
329323
coin = self.row_to_coin(row)
330324
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
331-
coinbase = False if row[2] == 0 else True
332-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
325+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
333326

334327
return list(coins)
335328

@@ -400,8 +393,7 @@ async def get_coin_records_by_parent_ids(
400393
async for row in cursor:
401394
coin = self.row_to_coin(row)
402395
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
403-
coinbase = False if row[2] == 0 else True
404-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
396+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
405397

406398
return list(coins)
407399

@@ -575,8 +567,7 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
575567
for row in rows:
576568
coin = self.row_to_coin(row)
577569
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
578-
coinbase = False if row[2] == 0 else True
579-
record = CoinRecord(coin, uint32(0), spent_index, coinbase, uint64(0))
570+
record = CoinRecord(coin, uint32(0), spent_index, row[2] != 0, uint64(0))
580571
coin_name = bytes32(row[7])
581572
coin_changes[coin_name] = record
582573

@@ -591,8 +582,7 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
591582
)
592583
for row in rows:
593584
coin = self.row_to_coin(row)
594-
coinbase = False if row[2] == 0 else True
595-
record = CoinRecord(coin, row[0], uint32(0), coinbase, row[6])
585+
record = CoinRecord(coin, row[0], uint32(0), row[2] != 0, row[6])
596586
coin_name = bytes32(row[7])
597587
if coin_name not in coin_changes:
598588
coin_changes[coin_name] = record

0 commit comments

Comments
 (0)