1
1
use chia:: { clvm_utils:: ToTreeHash , protocol:: Bytes32 } ;
2
+ use chia_puzzle_types:: LineageProof ;
2
3
use chia_wallet_sdk:: {
3
4
coinset:: CoinRecord ,
4
- driver:: { DriverError , RewardDistributorConstants , Slot , SlotProof , XchandlesConstants } ,
5
+ driver:: { DriverError , RewardDistributorConstants , Slot , XchandlesConstants } ,
5
6
types:: puzzles:: SlotInfo ,
6
7
} ;
7
8
use clvm_traits:: { FromClvm , ToClvm } ;
@@ -37,9 +38,10 @@ impl Db {
37
38
slot_value_hash BLOB NOT NULL,
38
39
spent_block_height INTEGER NOT NULL,
39
40
slot_value BLOB NOT NULL,
40
- parent_parent_info BLOB NOT NULL,
41
+ parent_parent_coin_info BLOB NOT NULL,
41
42
parent_inner_puzzle_hash BLOB NOT NULL,
42
- PRIMARY KEY (singleton_launcher_id, nonce, slot_value_hash, parent_parent_info)
43
+ parent_amount INTEGER NOT NULL,
44
+ PRIMARY KEY (singleton_launcher_id, nonce, slot_value_hash, parent_parent_coin_info, parent_amount)
43
45
)
44
46
" ,
45
47
)
@@ -147,19 +149,20 @@ impl Db {
147
149
"
148
150
INSERT INTO slots (
149
151
singleton_launcher_id, nonce, slot_value_hash, spent_block_height,
150
- slot_value, parent_parent_info , parent_inner_puzzle_hash
152
+ slot_value, parent_parent_coin_info , parent_inner_puzzle_hash, parent_amount
151
153
)
152
- VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)
153
- ON CONFLICT(singleton_launcher_id, nonce, slot_value_hash, parent_parent_info ) DO UPDATE SET spent_block_height = excluded.spent_block_height
154
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8 )
155
+ ON CONFLICT(singleton_launcher_id, nonce, slot_value_hash, parent_parent_coin_info, parent_amount ) DO UPDATE SET spent_block_height = excluded.spent_block_height
154
156
" ,
155
157
)
156
158
. bind ( slot. info . launcher_id . to_vec ( ) )
157
159
. bind ( slot. info . nonce as i64 )
158
160
. bind ( slot. info . value_hash . to_vec ( ) )
159
161
. bind ( spent_block_height)
160
162
. bind ( slot_value_bytes)
161
- . bind ( slot. proof . parent_parent_info . to_vec ( ) )
163
+ . bind ( slot. proof . parent_parent_coin_info . to_vec ( ) )
162
164
. bind ( slot. proof . parent_inner_puzzle_hash . to_vec ( ) )
165
+ . bind ( slot. proof . parent_amount as i64 )
163
166
. execute ( & self . pool )
164
167
. await
165
168
. map_err ( CliError :: Sqlx ) ?;
@@ -173,18 +176,21 @@ impl Db {
173
176
{
174
177
let launcher_id = column_to_bytes32 ( row. get :: < & [ u8 ] , _ > ( "singleton_launcher_id" ) ) ?;
175
178
let nonce = row. get :: < i64 , _ > ( "nonce" ) as u64 ;
176
- let parent_parent_info = column_to_bytes32 ( row. get :: < & [ u8 ] , _ > ( "parent_parent_info" ) ) ?;
179
+ let parent_parent_coin_info =
180
+ column_to_bytes32 ( row. get :: < & [ u8 ] , _ > ( "parent_parent_coin_info" ) ) ?;
177
181
let parent_inner_puzzle_hash =
178
182
column_to_bytes32 ( row. get :: < & [ u8 ] , _ > ( "parent_inner_puzzle_hash" ) ) ?;
183
+ let parent_amount = row. get :: < i64 , _ > ( "parent_amount" ) as u64 ;
179
184
180
185
let value = node_from_bytes ( allocator, row. get :: < & [ u8 ] , _ > ( "slot_value" ) ) ?;
181
186
let value = SV :: from_clvm ( allocator, value)
182
187
. map_err ( |err| CliError :: Driver ( DriverError :: FromClvm ( err) ) ) ?;
183
188
184
189
Ok ( Slot :: new (
185
- SlotProof {
186
- parent_parent_info ,
190
+ LineageProof {
191
+ parent_parent_coin_info ,
187
192
parent_inner_puzzle_hash,
193
+ parent_amount,
188
194
} ,
189
195
SlotInfo :: < SV > :: from_value ( launcher_id, nonce, value) ,
190
196
) )
0 commit comments