zsync-rs 0.3.0

Efficient file transfer using rsync algorithm over HTTP
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
//! Finding target blocks in local data, and tracking which are known.
//!
//! [`BlockMatcher`] indexes the target's block checksums and then tests every
//! byte offset of the data it is given. The rolling checksum slides along one
//! byte at a time, a bit filter and a hash table reject most offsets without
//! a lookup, and MD4 confirms what survives. With
//! [`HashLengths::seq_matches`] of 2, a match that does not continue the
//! previous one counts only when the block after it matches too, which keeps
//! short rolling checksums from producing false matches. On a machine with
//! more than one core, inputs of 4 MiB and more are split across threads.

use crate::checksum::calc_md4;
use crate::control::{ControlFile, HashLengths};
use crate::rsum::{Rsum, calc_rsum_block};

/// Why matching failed.
#[derive(Debug, thiserror::Error)]
pub enum MatchError {
    /// An I/O error. Not currently returned by this crate.
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),
}

const HASH_EMPTY: u32 = u32::MAX;
const BITHASH_BITS: u32 = 3;

#[derive(Debug, Clone, Copy)]
struct TargetBlock {
    rsum: Rsum,
    checksum: [u8; 16],
}

/// The contribution of a byte leaving the window to the rolling `b` sum,
/// which is the byte shifted left by `log2(blocksize)`, modulo 2^16.
///
/// A plain `u16` shift overflows once the block size reaches 64 KiB, which
/// panics in debug builds and wraps the shift amount in release, so the
/// rolling sum stops matching blocks at unaligned offsets.
#[inline(always)]
fn shifted_out(byte: u8, blockshift: u8) -> u16 {
    u16::from(byte)
        .checked_shl(u32::from(blockshift))
        .unwrap_or(0)
}

/// Read-only scan state shared across threads.
struct ScanState<'a> {
    targets: &'a [TargetBlock],
    hash_table: &'a [u32],
    hash_next: &'a [u32],
    bithash: &'a [u8],
    blocksize: usize,
    blockshift: u8,
    seq_matches: usize,
    checksum_bytes: usize,
    rsum_a_mask: u16,
    hash_func_shift: u32,
    hash_mask: u32,
    bithash_mask: u32,
}

impl ScanState<'_> {
    #[inline(always)]
    fn calc_hash_rolling(&self, r0: &Rsum, r1: &Rsum) -> u32 {
        let mut h = r0.b as u32;
        if self.seq_matches > 1 {
            h ^= (r1.b as u32) << self.hash_func_shift;
        } else {
            h ^= ((r0.a & self.rsum_a_mask) as u32) << self.hash_func_shift;
        }
        h
    }

    #[inline(always)]
    fn rsum_match(&self, target: &Rsum, rolling: &Rsum) -> bool {
        target.a == (rolling.a & self.rsum_a_mask) && target.b == rolling.b
    }

    /// Scan a chunk of data for matching blocks. Pure read-only, no mutations.
    /// `base_offset` is the absolute byte offset of `data[0]` within the source file.
    /// Returns vec of (target_block_id, absolute_source_offset).
    fn scan_chunk(&self, data: &[u8], base_offset: usize) -> Vec<(usize, usize)> {
        let blocksize = self.blocksize;
        let blockshift = self.blockshift;
        let seq_matches = self.seq_matches;
        let checksum_bytes = self.checksum_bytes;
        let context = blocksize * seq_matches;
        let mut matched_blocks = Vec::new();

        if data.len() < context {
            return matched_blocks;
        }

        let x_limit = data.len() - context;
        let mut x = 0usize;
        let mut next_match_id: Option<usize> = None;

        let mut r0 = calc_rsum_block(&data[0..blocksize]);
        let mut r1 = if seq_matches > 1 {
            calc_rsum_block(&data[blocksize..blocksize * 2])
        } else {
            Rsum { a: 0, b: 0 }
        };

        while x < x_limit {
            let mut blocks_matched = 0usize;

            if let Some(hint_id) = next_match_id.take()
                && seq_matches > 1
                && hint_id < self.targets.len()
            {
                let target = &self.targets[hint_id];
                if self.rsum_match(&target.rsum, &r0) {
                    let checksum = calc_md4(&data[x..x + blocksize]);
                    if checksum[..checksum_bytes] == target.checksum[..checksum_bytes] {
                        matched_blocks.push((hint_id, base_offset + x));
                        blocks_matched = 1;
                        if hint_id + 1 < self.targets.len() {
                            next_match_id = Some(hint_id + 1);
                        }
                    }
                }
            }

            while blocks_matched == 0 && x < x_limit {
                let hash = self.calc_hash_rolling(&r0, &r1);

                let bh = (hash & self.bithash_mask) as usize;
                if self.bithash[bh >> 3] & (1 << (bh & 7)) != 0 {
                    let mut block_idx = self.hash_table[(hash & self.hash_mask) as usize];

                    while block_idx != HASH_EMPTY {
                        let block_id = block_idx as usize;
                        block_idx = self.hash_next[block_id];

                        let target = &self.targets[block_id];
                        if !self.rsum_match(&target.rsum, &r0) {
                            continue;
                        }

                        if seq_matches > 1 && block_id + 1 < self.targets.len() {
                            let next_target = &self.targets[block_id + 1];
                            if !self.rsum_match(&next_target.rsum, &r1) {
                                continue;
                            }

                            let checksum = calc_md4(&data[x..x + blocksize]);
                            if checksum[..checksum_bytes] != target.checksum[..checksum_bytes] {
                                continue;
                            }

                            let next_checksum = calc_md4(&data[x + blocksize..x + blocksize * 2]);
                            if next_checksum[..checksum_bytes]
                                == next_target.checksum[..checksum_bytes]
                            {
                                matched_blocks.push((block_id, base_offset + x));
                                matched_blocks.push((block_id + 1, base_offset + x + blocksize));
                                blocks_matched = seq_matches;

                                if block_id + 2 < self.targets.len() {
                                    next_match_id = Some(block_id + 2);
                                }
                                break;
                            }
                        } else {
                            let checksum = calc_md4(&data[x..x + blocksize]);
                            if checksum[..checksum_bytes] == target.checksum[..checksum_bytes] {
                                matched_blocks.push((block_id, base_offset + x));
                                blocks_matched = 1;
                                break;
                            }
                        }
                    }
                }

                if blocks_matched == 0 {
                    let oc = data[x];
                    let nc = data[x + blocksize];
                    r0.a = r0.a.wrapping_add(u16::from(nc)).wrapping_sub(u16::from(oc));
                    r0.b =
                        r0.b.wrapping_add(r0.a)
                            .wrapping_sub(shifted_out(oc, blockshift));

                    if seq_matches > 1 {
                        let nc2 = data[x + blocksize * 2];
                        r1.a =
                            r1.a.wrapping_add(u16::from(nc2))
                                .wrapping_sub(u16::from(nc));
                        r1.b =
                            r1.b.wrapping_add(r1.a)
                                .wrapping_sub(shifted_out(nc, blockshift));
                    }

                    x += 1;
                }
            }

            if blocks_matched > 0 {
                x += blocksize * blocks_matched;

                if x >= x_limit {
                    // Can't calculate rsums for remaining data
                } else {
                    if seq_matches > 1 && blocks_matched == 1 {
                        r0 = r1;
                    } else {
                        r0 = calc_rsum_block(&data[x..x + blocksize]);
                    }
                    if seq_matches > 1 {
                        r1 = calc_rsum_block(&data[x + blocksize..x + blocksize * 2]);
                    }
                }
            }
        }

        matched_blocks
    }
}

/// The index of a target's blocks and the record of which are known.
///
/// Every block starts unknown. A block becomes known when a scan finds it in
/// local data or when downloaded data verifies against its checksum, and the
/// blocks still unknown are what remains to download.
pub struct BlockMatcher {
    blocksize: usize,
    blockshift: u8,
    hash_lengths: HashLengths,
    rsum_a_mask: u16,
    hash_func_shift: u32,
    targets: Vec<TargetBlock>,
    known_blocks: Vec<bool>,
    /// How many entries of `known_blocks` are set, kept so that progress
    /// queries after every downloaded block do not rescan the whole vector.
    known_count: usize,
    hash_table: Vec<u32>,
    hash_next: Vec<u32>,
    hash_mask: u32,
    bithash: Vec<u8>,
    bithash_mask: u32,
}

impl BlockMatcher {
    /// Indexes the block checksums in `control`, with every block unknown.
    pub fn new(control: &ControlFile) -> Self {
        let num_blocks = control.block_checksums.len();
        let seq_matches = control.hash_lengths.seq_matches as u32;
        let rsum_bytes = control.hash_lengths.rsum_bytes as u32;

        let rsum_a_mask: u16 = match rsum_bytes {
            0..=2 => 0,
            3 => 0x00ff,
            _ => 0xffff,
        };

        let targets: Vec<TargetBlock> = control
            .block_checksums
            .iter()
            .map(|bc| TargetBlock {
                rsum: Rsum {
                    a: bc.rsum.a & rsum_a_mask,
                    b: bc.rsum.b,
                },
                checksum: bc.checksum,
            })
            .collect();

        let rsum_bits = rsum_bytes * 8;
        let avail_bits = if seq_matches > 1 {
            rsum_bits.min(16) * 2
        } else {
            rsum_bits
        };

        let mut hash_bits = avail_bits;
        while hash_bits > 5 && (1u32 << (hash_bits - 1)) > num_blocks as u32 {
            hash_bits -= 1;
        }
        let hash_mask = (1u32 << hash_bits) - 1;

        // Safe only because the parser caps a control file at 2^26 blocks,
        // which holds hash_bits at 27 and this sum at 30. Raising that cap
        // past 2^28 makes this reach 32, where the shift below overflows:
        // a panic in debug, and a mask that collapses every bucket to one
        // in release.
        let bithash_bits_total = (hash_bits + BITHASH_BITS).min(avail_bits);
        let bithash_mask = (1u32 << bithash_bits_total) - 1;

        let hash_func_shift = if seq_matches > 1 && avail_bits < 24 {
            bithash_bits_total.saturating_sub(avail_bits / 2)
        } else {
            bithash_bits_total.saturating_sub(avail_bits - 16)
        };

        let blockshift = control.blocksize.trailing_zeros() as u8;

        let mut matcher = Self {
            blocksize: control.blocksize,
            blockshift,
            hash_lengths: control.hash_lengths,
            rsum_a_mask,
            hash_func_shift,
            targets,
            known_blocks: vec![false; num_blocks],
            known_count: 0,
            hash_table: vec![HASH_EMPTY; (hash_mask + 1) as usize],
            hash_next: vec![HASH_EMPTY; num_blocks],
            hash_mask,
            bithash: vec![0u8; ((bithash_mask + 1) >> 3) as usize + 1],
            bithash_mask,
        };

        for id in (0..num_blocks).rev() {
            let h = matcher.calc_hash(id);
            let bucket = (h & hash_mask) as usize;
            matcher.hash_next[id] = matcher.hash_table[bucket];
            matcher.hash_table[bucket] = id as u32;
            let bh = (h & bithash_mask) as usize;
            matcher.bithash[bh >> 3] |= 1 << (bh & 7);
        }

        matcher
    }

    fn calc_hash(&self, block_id: usize) -> u32 {
        let mut h = self.targets[block_id].rsum.b as u32;
        if self.hash_lengths.seq_matches > 1 {
            let next_b = if block_id + 1 < self.targets.len() {
                self.targets[block_id + 1].rsum.b as u32
            } else {
                0
            };
            h ^= next_b << self.hash_func_shift;
        } else {
            h ^= (self.targets[block_id].rsum.a as u32) << self.hash_func_shift;
        }
        h
    }

    fn remove_block_from_hash(&mut self, id: usize) {
        let h = self.calc_hash(id);
        let bucket = (h & self.hash_mask) as usize;

        let mut prev = HASH_EMPTY;
        let mut curr = self.hash_table[bucket];

        while curr != HASH_EMPTY {
            if curr as usize == id {
                if prev == HASH_EMPTY {
                    self.hash_table[bucket] = self.hash_next[id];
                } else {
                    self.hash_next[prev as usize] = self.hash_next[id];
                }
                return;
            }
            prev = curr;
            curr = self.hash_next[curr as usize];
        }
    }

    fn mark_known(&mut self, block_id: usize) {
        if !self.known_blocks[block_id] {
            self.known_blocks[block_id] = true;
            self.known_count += 1;
        }
    }

    fn scan_state(&self) -> ScanState<'_> {
        ScanState {
            targets: &self.targets,
            hash_table: &self.hash_table,
            hash_next: &self.hash_next,
            bithash: &self.bithash,
            blocksize: self.blocksize,
            blockshift: self.blockshift,
            seq_matches: self.hash_lengths.seq_matches as usize,
            checksum_bytes: self.hash_lengths.checksum_bytes as usize,
            rsum_a_mask: self.rsum_a_mask,
            hash_func_shift: self.hash_func_shift,
            hash_mask: self.hash_mask,
            bithash_mask: self.bithash_mask,
        }
    }

    /// Verifies `data` as consecutive whole blocks starting at block
    /// `block_start`, marking each one that matches its checksum as known.
    ///
    /// A final block shorter than the block size must be padded with zeros
    /// to a full block, as the checksums were computed that way. Trailing
    /// bytes short of a block are ignored, as are blocks past the end of the
    /// target. Verification stops at the first mismatch and returns `false`,
    /// leaving the blocks before it known.
    ///
    /// # Errors
    ///
    /// None at present. The `Result` leaves room for one.
    pub fn submit_blocks(&mut self, data: &[u8], block_start: usize) -> Result<bool, MatchError> {
        let blocksize = self.blocksize;
        let checksum_bytes = self.hash_lengths.checksum_bytes as usize;
        let num_blocks = data.len() / blocksize;

        for i in 0..num_blocks {
            let block_data = &data[i * blocksize..(i + 1) * blocksize];
            let block_id = block_start + i;

            if block_id >= self.targets.len() {
                break;
            }

            let checksum = calc_md4(block_data);
            if checksum[..checksum_bytes] == self.targets[block_id].checksum[..checksum_bytes] {
                self.mark_known(block_id);
            } else {
                return Ok(false);
            }
        }

        Ok(true)
    }

    /// Scans `data` for target blocks at every byte offset and marks the ones
    /// found as known.
    ///
    /// `offset` is where `data` starts in its source, and the returned
    /// `(block_id, source_offset)` pairs give absolute offsets in that
    /// source. Offsets are tested only up to `blocksize * seq_matches` bytes
    /// before the end of `data`, so a caller scanning a file in chunks must
    /// overlap them by that much and pad the end of the file with zeros.
    ///
    /// Only blocks that were not already known are reported, each once at the
    /// first offset found, so the result counts what this scan added.
    pub fn submit_source_data(&mut self, data: &[u8], offset: u64) -> Vec<(usize, usize)> {
        let context = self.blocksize * self.hash_lengths.seq_matches as usize;
        if data.len() < context {
            return Vec::new();
        }

        let num_threads = std::thread::available_parallelism()
            .map(|n| n.get())
            .unwrap_or(1);

        // Below this, starting a thread costs more than its share saves.
        let min_per_thread = 2 * 1024 * 1024;
        let scannable = data.len() - context;

        let candidates = if num_threads > 1 && scannable >= min_per_thread * 2 {
            let state = self.scan_state();
            let actual_threads = num_threads.min(scannable / min_per_thread);
            let chunk_size = scannable / actual_threads;

            std::thread::scope(|s| {
                let handles: Vec<_> = (0..actual_threads)
                    .map(|i| {
                        let start = i * chunk_size;
                        let end = if i == actual_threads - 1 {
                            data.len()
                        } else {
                            (i + 1) * chunk_size + context
                        };
                        let chunk = &data[start..end];
                        let state = &state;
                        let base = offset as usize + start;
                        s.spawn(move || state.scan_chunk(chunk, base))
                    })
                    .collect();

                let mut all: Vec<(usize, usize)> = Vec::new();
                for h in handles {
                    all.extend(h.join().unwrap());
                }
                all
            })
        } else {
            let state = self.scan_state();
            state.scan_chunk(data, offset as usize)
        };

        // A pair match also reports its second block, and chunks overlap, so
        // candidates can repeat a block or name one already known. Only the
        // first sighting of a still unknown block counts.
        let mut matched_blocks = Vec::new();
        for (block_id, offset) in candidates {
            if !self.known_blocks[block_id] {
                self.mark_known(block_id);
                self.remove_block_from_hash(block_id);
                matched_blocks.push((block_id, offset));
            }
        }

        matched_blocks
    }

    /// The runs of blocks still unknown, as half-open `(first, end)` ranges
    /// in ascending order.
    pub fn needed_block_ranges(&self) -> Vec<(usize, usize)> {
        let mut ranges = Vec::new();
        let mut start: Option<usize> = None;

        for (i, &known) in self.known_blocks.iter().enumerate() {
            if !known && start.is_none() {
                start = Some(i);
            } else if known && start.is_some() {
                ranges.push((start.unwrap(), i));
                start = None;
            }
        }

        if let Some(s) = start {
            ranges.push((s, self.known_blocks.len()));
        }

        ranges
    }

    /// Whether block `block_id` is known, which is `false` past the end of the
    /// target.
    pub fn is_block_known(&self, block_id: usize) -> bool {
        block_id < self.known_blocks.len() && self.known_blocks[block_id]
    }

    /// The number of blocks still unknown.
    pub fn blocks_todo(&self) -> usize {
        self.known_blocks.len() - self.known_count
    }

    /// Whether every block is known.
    pub fn is_complete(&self) -> bool {
        self.known_count == self.known_blocks.len()
    }

    /// The number of blocks in the target.
    pub fn total_blocks(&self) -> usize {
        self.targets.len()
    }
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::control::{BlockChecksum, ControlFile, HashLengths};

    fn make_control(data: &[u8], blocksize: usize) -> ControlFile {
        let num_blocks = data.len().div_ceil(blocksize);
        let mut block_checksums = Vec::with_capacity(num_blocks);

        for i in 0..num_blocks {
            let start = i * blocksize;
            let end = std::cmp::min(start + blocksize, data.len());
            let mut block = data[start..end].to_vec();
            block.resize(blocksize, 0);

            let rsum = calc_rsum_block(&block);
            let checksum = calc_md4(&block);

            block_checksums.push(BlockChecksum { rsum, checksum });
        }

        ControlFile {
            version: "0.6.2".to_string(),
            filename: Some("test.bin".to_string()),
            mtime: None,
            blocksize,
            length: data.len() as u64,
            hash_lengths: HashLengths {
                seq_matches: 1,
                rsum_bytes: 4,
                checksum_bytes: 16,
            },
            urls: vec!["http://example.com/test.bin".to_string()],
            sha1: None,
            block_checksums,
        }
    }

    #[test]
    fn test_matcher_new() {
        let data = vec![1u8, 2, 3, 4, 5, 6, 7, 8];
        let control = make_control(&data, 4);
        let matcher = BlockMatcher::new(&control);
        assert_eq!(matcher.blocks_todo(), 2);
    }

    #[test]
    fn test_submit_source_data() {
        let data = vec![1u8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
        let control = make_control(&data, 4);
        let mut matcher = BlockMatcher::new(&control);

        // Pad with context bytes (blocksize * seq_matches) like submit_source_file does
        let mut padded = data.clone();
        padded.resize(data.len() + 4, 0);
        let got = matcher.submit_source_data(&padded, 0);
        assert_eq!(got.len(), 3);
        assert!(matcher.is_complete());
    }

    #[test]
    fn large_blocks_match_at_unaligned_offsets() {
        // 64 KiB blocks shift the leaving byte by 16, past the width of the
        // rolling sum. The seed starts one byte late, so every match needs
        // the rolling update to be right.
        let blocksize = 64 * 1024;
        let data: Vec<u8> = (0..blocksize as u32 * 3)
            .map(|i| (i.wrapping_mul(2_654_435_761) >> 13) as u8)
            .collect();
        let control = make_control(&data, blocksize);
        let mut matcher = BlockMatcher::new(&control);

        let mut seed = vec![0xAA];
        seed.extend_from_slice(&data);
        seed.resize(seed.len() + blocksize, 0);
        let found = matcher.submit_source_data(&seed, 0);

        assert_eq!(found.len(), 3, "found {found:?}");
        assert!(
            found
                .iter()
                .all(|&(id, offset)| offset == id * blocksize + 1)
        );
    }

    #[test]
    fn a_block_known_twice_is_counted_once() {
        let data: Vec<u8> = (0..16u8).collect();
        let control = make_control(&data, 4);
        let mut matcher = BlockMatcher::new(&control);

        // Block 1 verified by download, then found again by a scan that
        // covers it. Counting it twice would report completion early.
        assert!(matcher.submit_blocks(&data[4..8], 1).unwrap());
        assert!(matcher.submit_blocks(&data[4..8], 1).unwrap());
        assert_eq!(matcher.blocks_todo(), 3);

        let mut padded = data[..8].to_vec();
        padded.resize(12, 0);
        let found = matcher.submit_source_data(&padded, 0);
        assert_eq!(found, vec![(0, 0)], "only the newly found block counts");
        assert_eq!(matcher.blocks_todo(), 2);
        assert!(!matcher.is_complete());
    }

    #[test]
    fn test_needed_block_ranges() {
        let data = vec![1u8, 2, 3, 4, 5, 6, 7, 8];
        let control = make_control(&data, 4);
        let matcher = BlockMatcher::new(&control);
        let ranges = matcher.needed_block_ranges();
        assert_eq!(ranges, vec![(0, 2)]);
    }
}