Skip to content

Commit bd7aeb5

Browse files
committed
inline coinstore bool
1 parent 0236cf2 commit bd7aeb5

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
@@ -173,8 +173,7 @@ async def get_coin_record(self, coin_name: bytes32) -> Optional[CoinRecord]:
173173
if row is not None:
174174
coin = self.row_to_coin(row)
175175
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
176-
coinbase = False if row[2] == 0 else True
177-
return CoinRecord(coin, row[0], spent_index, coinbase, row[6])
176+
return CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6])
178177
return None
179178

180179
async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]:
@@ -200,8 +199,7 @@ async def get_coin_records(self, names: Collection[bytes32]) -> list[CoinRecord]
200199
for row in await cursor.fetchall():
201200
coin = self.row_to_coin(row)
202201
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
203-
coinbase = False if row[2] == 0 else True
204-
record = CoinRecord(coin, row[0], spent_index, coinbase, row[6])
202+
record = CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6])
205203
coins.append(record)
206204

207205
return coins
@@ -218,8 +216,7 @@ async def get_coins_added_at_height(self, height: uint32) -> list[CoinRecord]:
218216
for row in rows:
219217
coin = self.row_to_coin(row)
220218
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
221-
coinbase = False if row[2] == 0 else True
222-
coins.append(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
219+
coins.append(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
223220
return coins
224221

225222
async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
@@ -236,8 +233,7 @@ async def get_coins_removed_at_height(self, height: uint32) -> list[CoinRecord]:
236233
for row in await cursor.fetchall():
237234
if row[1] > 0:
238235
coin = self.row_to_coin(row)
239-
coinbase = False if row[2] == 0 else True
240-
coin_record = CoinRecord(coin, row[0], row[1], coinbase, row[6])
236+
coin_record = CoinRecord(coin, row[0], row[1], row[2] != 0, row[6])
241237
coins.append(coin_record)
242238
return coins
243239

@@ -262,8 +258,7 @@ async def get_coin_records_by_puzzle_hash(
262258
for row in await cursor.fetchall():
263259
coin = self.row_to_coin(row)
264260
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
265-
coinbase = False if row[2] == 0 else True
266-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
261+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
267262
return list(coins)
268263

269264
async def get_coin_records_by_puzzle_hashes(
@@ -292,8 +287,7 @@ async def get_coin_records_by_puzzle_hashes(
292287
for row in await cursor.fetchall():
293288
coin = self.row_to_coin(row)
294289
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
295-
coinbase = False if row[2] == 0 else True
296-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
290+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
297291
return list(coins)
298292

299293
async def get_coin_records_by_names(
@@ -320,8 +314,7 @@ async def get_coin_records_by_names(
320314
for row in await cursor.fetchall():
321315
coin = self.row_to_coin(row)
322316
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
323-
coinbase = False if row[2] == 0 else True
324-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
317+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
325318

326319
return list(coins)
327320

@@ -392,8 +385,7 @@ async def get_coin_records_by_parent_ids(
392385
async for row in cursor:
393386
coin = self.row_to_coin(row)
394387
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
395-
coinbase = False if row[2] == 0 else True
396-
coins.add(CoinRecord(coin, row[0], spent_index, coinbase, row[6]))
388+
coins.add(CoinRecord(coin, row[0], spent_index, row[2] != 0, row[6]))
397389

398390
return list(coins)
399391

@@ -567,8 +559,7 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
567559
for row in rows:
568560
coin = self.row_to_coin(row)
569561
spent_index = uint32(0) if row[1] <= 0 else uint32(row[1])
570-
coinbase = False if row[2] == 0 else True
571-
record = CoinRecord(coin, uint32(0), spent_index, coinbase, uint64(0))
562+
record = CoinRecord(coin, uint32(0), spent_index, row[2] != 0, uint64(0))
572563
coin_name = bytes32(row[7])
573564
coin_changes[coin_name] = record
574565

@@ -583,8 +574,7 @@ async def rollback_to_block(self, block_index: int) -> dict[bytes32, CoinRecord]
583574
)
584575
for row in rows:
585576
coin = self.row_to_coin(row)
586-
coinbase = False if row[2] == 0 else True
587-
record = CoinRecord(coin, row[0], uint32(0), coinbase, row[6])
577+
record = CoinRecord(coin, row[0], uint32(0), row[2] != 0, row[6])
588578
coin_name = bytes32(row[7])
589579
if coin_name not in coin_changes:
590580
coin_changes[coin_name] = record

0 commit comments

Comments
 (0)