|
1 |
| -use ckb_bitcoin_spv_verifier::types::{core::SpvTypeArgs, packed::SpvInfoReader, prelude::*}; |
2 |
| -use ckb_std::{ckb_constants::Source, debug, high_level as hl}; |
3 |
| - |
4 |
| -use crate::{ |
5 |
| - error::{InternalError, Result}, |
6 |
| - utilities, |
7 |
| -}; |
8 |
| - |
9 |
| -pub(crate) fn reset_cells( |
10 |
| - inputs: &[usize], |
11 |
| - outputs: &[usize], |
12 |
| - type_args: SpvTypeArgs, |
13 |
| -) -> Result<()> { |
14 |
| - if inputs.windows(2).any(|pair| pair[1] + 1 != pair[0]) { |
15 |
| - return Err(InternalError::CreateShouldBeOrdered.into()); |
16 |
| - } |
17 |
| - if outputs.windows(2).any(|pair| pair[1] + 1 != pair[0]) { |
18 |
| - return Err(InternalError::CreateShouldBeOrdered.into()); |
19 |
| - } |
20 |
| - // Checks args of the client type script, then returns the clients count; |
21 |
| - let _clients_count = { |
22 |
| - let clients_count = usize::from(type_args.clients_count); |
23 |
| - let cells_count = 1 + clients_count; |
24 |
| - if outputs.len() != cells_count { |
25 |
| - return Err(InternalError::CreateCellsCountNotMatched.into()); |
26 |
| - } |
27 |
| - let type_id = utilities::load_then_calculate_type_id(outputs.len())?; |
28 |
| - if type_id != type_args.type_id.as_ref() { |
29 |
| - return Err(InternalError::CreateIncorrectUniqueId.into()); |
30 |
| - } |
31 |
| - clients_count |
32 |
| - }; |
33 |
| - // First cell is the client info cell. |
34 |
| - let index = outputs[0]; |
35 |
| - { |
36 |
| - debug!("check client info cell (index={index})"); |
37 |
| - let output_data = hl::load_cell_data(index, Source::Output)?; |
38 |
| - let packed_info = SpvInfoReader::from_slice(&output_data) |
39 |
| - .map_err(|_| InternalError::CreateBadInfoCellData)?; |
40 |
| - debug!("actual client info cell: {packed_info}"); |
41 |
| - let info = packed_info.unpack(); |
42 |
| - if info.tip_client_id != 0 { |
43 |
| - return Err(InternalError::CreateInfoIndexShouldBeZero.into()); |
44 |
| - } |
45 |
| - } |
| 1 | +use crate::error::Result; |
46 | 2 |
|
| 3 | +pub(crate) fn reset_cells() -> Result<()> { |
47 | 4 | Ok(())
|
48 | 5 | }
|
0 commit comments