Skip to content

Commit cc00bf5

Browse files
authored
CHIA-2989 Insert DB values in CoinStore's new_block without creating coin records for them (#19662)
Insert DB values in CoinStore's new_block without creating coin records for them.
1 parent f57dfc0 commit cc00bf5

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

chia/full_node/coin_store.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,34 +91,49 @@ async def new_block(
9191

9292
start = time.monotonic()
9393

94-
additions = []
94+
db_values_to_insert = []
9595

9696
for coin in tx_additions:
97-
record: CoinRecord = CoinRecord(
98-
coin,
99-
height,
100-
uint32(0),
101-
False,
102-
timestamp,
97+
db_values_to_insert.append(
98+
(
99+
coin.name(),
100+
# confirmed_index
101+
height,
102+
# spent_index
103+
0,
104+
# coinbase
105+
0,
106+
coin.puzzle_hash,
107+
coin.parent_coin_info,
108+
coin.amount.stream_to_bytes(),
109+
timestamp,
110+
)
103111
)
104-
additions.append(record)
105112

106113
if height == 0:
107114
assert len(included_reward_coins) == 0
108115
else:
109116
assert len(included_reward_coins) >= 2
110117

111118
for coin in included_reward_coins:
112-
reward_coin_r: CoinRecord = CoinRecord(
113-
coin,
114-
height,
115-
uint32(0),
116-
True,
117-
timestamp,
119+
db_values_to_insert.append(
120+
(
121+
coin.name(),
122+
# confirmed_index
123+
height,
124+
# spent_index
125+
0,
126+
# coinbase
127+
1,
128+
coin.puzzle_hash,
129+
coin.parent_coin_info,
130+
coin.amount.stream_to_bytes(),
131+
timestamp,
132+
)
118133
)
119-
additions.append(reward_coin_r)
120134

121-
await self._add_coin_records(additions)
135+
async with self.db_wrapper.writer_maybe_transaction() as conn:
136+
await conn.executemany("INSERT INTO coin_record VALUES(?, ?, ?, ?, ?, ?, ?, ?)", db_values_to_insert)
122137
await self._set_spent(tx_removals, height)
123138

124139
end = time.monotonic()

0 commit comments

Comments
 (0)