Changing the type of the tags db, to make it identical to remote tags

pmeunier
Dec 20, 2021, 11:23 AM
5MRZLKBHOFFUAJELWL34XILG2XVWPUEHOFPDXBK5ASCO6H26MBFAC

Dependencies

  • [2] C267PHOH Tags: dropping useless Hashes in favour of Merkles
  • [3] 7ZROQSSN Handling TAG uploads from the `pijul protocol` command
  • [4] RIAA2QKF Making Merkle std::hash::Hash
  • [5] RM225IDQ Exchanging tagged states over SSH
  • [6] CCLLB7OI Upgrading to Sanakirja 0.15 + version bump
  • [7] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [8] GHO6DWPI Refactoring iterators
  • [9] I24UEJQL Various post-fire fixes
  • [10] FDEVV5NG Tag check
  • [11] WTQCVLAH Correctly putting states into channels
  • [12] VO5OQW4W Removing anyhow in libpijul
  • [13] BUM5P4VG Correct error for Merkle::from_base32
  • [14] AAXP2534 Tags: completing the subcommand
  • [15] DX2FO4HZ Tag CLI cleanup
  • [16] YN63NUZO Sanakirja 1.0
  • [17] FXEDPLRI Resurrecting tests, and type cleanup (no need for Arc<RwLock<…>> anymore)
  • [18] IIV3EL2X Cleanup, formatting, and fixing the Git feature
  • [19] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [20] QL6K2ZM3 Tags
  • [21] A3RM526Y Integrating identity malleability
  • [*] IVLLXQ5Z Improved push/pull reporting
  • [*] I52XSRUH Massive cleanup, and simplification

Change contents

  • replacement in pijul/src/commands/tag.rs at line 114
    [6.3358][2.302:379]()
    txn.write().put_tags(&mut *channel.write(), last_t.into())?;
    [6.3358]
    [6.3432]
    txn.write()
    .put_tags(&mut channel.write().tags, last_t.into(), &h)?;
  • edit in pijul/src/commands/pushpull.rs at line 394
    [23.21985]
    [23.21985]
    tags,
  • replacement in pijul/src/commands/protocol.rs at line 182
    [3.1732][3.1732:1817]()
    txn.write().put_tags(&mut *channel.write(), last_t.into())?;
    [3.1732]
    [3.1817]
    txn.write()
    .put_tags(&mut channel.write().tags, last_t.into(), &m)?;
  • replacement in libpijul/src/tag.rs at line 227
    [6.12064][2.1907:1953]()
    |_, _, k: &L64, v: &()| Ok((*k, *v)),
    [6.12064]
    [6.12122]
    |_, _, k: &L64, v: &Pair<SerializedMerkle, SerializedMerkle>| Ok((*k, *v)),
  • replacement in libpijul/src/pristine/sanakirja.rs at line 340
    [6.25881][6.25881:25963]()
    let tags: UDb<L64, SerializedHash> = UDb::from_page(tup.tags.into());
    [6.25881]
    [6.62979]
    let tags: UDb<L64, Pair<SerializedMerkle, SerializedMerkle>> =
    UDb::from_page(tup.tags.into());
  • replacement in libpijul/src/pristine/sanakirja.rs at line 727
    [6.70500][2.3859:3886]()
    pub tags: Db<L64, ()>,
    [6.70500]
    [6.39127]
    pub tags: Db<L64, Pair<SerializedMerkle, SerializedMerkle>>,
  • replacement in libpijul/src/pristine/sanakirja.rs at line 927
    [6.23105][2.3887:3916]()
    type Tags = Db<L64, ()>;
    [6.23105]
    [2.3916]
    type Tags = Db<L64, Pair<SerializedMerkle, SerializedMerkle>>;
  • replacement in libpijul/src/pristine/sanakirja.rs at line 933
    [2.4139][2.4139:4166]()
    _ => Ok(false)
    [2.4139]
    [6.23430]
    _ => Ok(false),
  • replacement in libpijul/src/pristine/sanakirja.rs at line 937
    [6.23447][6.23447:23469](),[6.23469][2.4167:4232]()
    type TagsCursor =
    ::sanakirja::btree::cursor::Cursor<L64, (), P<L64, ()>>;
    [6.23447]
    [6.23559]
    type TagsCursor = ::sanakirja::btree::cursor::Cursor<
    L64,
    Pair<SerializedMerkle, SerializedMerkle>,
    P<L64, Pair<SerializedMerkle, SerializedMerkle>>,
    >;
  • replacement in libpijul/src/pristine/sanakirja.rs at line 988
    [6.2167][6.2167:2184](),[6.2184][2.4500:4563](),[2.4563][6.2259:2301](),[6.2259][6.2259:2301]()
    ) -> Result<
    super::Cursor<Self, &Self, Self::TagsCursor, L64, ()>,
    TxnErr<Self::GraphError>,
    > {
    [6.2167]
    [6.2301]
    ) -> Result<super::Cursor<Self, &Self, Self::TagsCursor, L64, ()>, TxnErr<Self::GraphError>>
    {
  • replacement in libpijul/src/pristine/sanakirja.rs at line 997
    [6.2455][6.2455:2472](),[6.2472][2.4564:4630](),[2.4630][6.2550:2592](),[6.2550][6.2550:2592]()
    ) -> Result<
    super::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
    TxnErr<Self::GraphError>,
    > {
    [6.2455]
    [6.2592]
    ) -> Result<super::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>, TxnErr<Self::GraphError>>
    {
  • edit in libpijul/src/pristine/sanakirja.rs at line 1382
    [6.79838]
    [6.79838]
    type Remotetags = UDb<L64, Pair<SerializedMerkle, SerializedMerkle>>;
  • edit in libpijul/src/pristine/sanakirja.rs at line 1391
    [6.554746]
    [6.554746]
    sanakirja_cursor!(remotetags, L64, Pair<SerializedMerkle, SerializedMerkle>);
    sanakirja_rev_cursor!(remotetags, L64, Pair<SerializedMerkle, SerializedMerkle>);
    type RemotetagsCursor = ::sanakirja::btree::cursor::Cursor<
    L64,
    Pair<SerializedMerkle, SerializedMerkle>,
    UP<L64, Pair<SerializedMerkle, SerializedMerkle>>,
    >;
  • edit in libpijul/src/pristine/sanakirja.rs at line 1474
    [6.556376]
    [6.48966]
    fn last_remote_tag(
    &self,
    remote: &Self::Remotetags,
    ) -> Result<Option<(u64, &SerializedMerkle, &SerializedMerkle)>, TxnErr<Self::GraphError>> {
    if let Some(x) = btree::rev_iter(&self.txn, remote, None)?.next() {
    let (&k, v) = x?;
    Ok(Some((k.into(), &v.a, &v.b)))
    } else {
    Ok(None)
    }
    }
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1674
    [6.83995][6.83995:84030]()
    (&(x?.1).b).into()
    [6.83995]
    [6.560596]
    let (a, b) = x?;
    let a: u64 = (*a).into();
    assert!(a < t);
    (&b.b).into()
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1734
    [6.85003][6.85003:85071]()
    m = m.next(&self.get_external(p)?.unwrap().into());
    [6.85003]
    [6.85071]
    m = m.next(self.get_external(p)?.unwrap());
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1755
    [6.25236][6.25236:25300]()
    channel: &mut Self::Channel,
    t: ApplyTimestamp,
    [6.25236]
    [6.25318]
    channel: &mut Self::Tags,
    n: u64,
    m: &Merkle,
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1759
    [6.25366][2.4690:4761](),[2.4761][6.25443:25458](),[6.25443][6.25443:25458]()
    btree::put(&mut self.txn, &mut channel.tags, &t.into(), &())?;
    Ok(())
    [6.25366]
    [6.25458]
    debug!("put_tags {:?}", m);
    let mm: SerializedMerkle = m.into();
    if btree::get(&self.txn, &channel, &n.into(), None)?.is_some() {
    debug!("already tagged");
    Ok(())
    } else {
    let tl = n.into();
    let mut repl = vec![(tl, mm)];
    replay_tags(self, channel, tl, &mut repl)?;
    Ok(())
    }
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1774
    [6.25501][6.25501:25565]()
    channel: &mut Self::Channel,
    t: ApplyTimestamp,
    [6.25501]
    [6.25565]
    channel: &mut Self::Tags,
    t: u64,
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1777
    [6.25613][6.25613:25685]()
    btree::del(&mut self.txn, &mut channel.tags, &t.into(), None)?;
    [6.25613]
    [6.25685]
    replay_tags(self, channel, t.into(), &mut Vec::new())?;
  • edit in libpijul/src/pristine/sanakirja.rs at line 1782
    [6.50939]
    [6.50939]
    fn replay_tags(
    txn: &mut MutTxn<()>,
    channel: &mut Db<L64, Pair<SerializedMerkle, SerializedMerkle>>,
    tl: L64,
    repl: &mut Vec<(L64, SerializedMerkle)>,
    ) -> Result<(), TxnErr<SanakirjaError>> {
    let del = repl.is_empty();
    for x in btree::iter(&txn.txn, &channel, Some((&tl, None)))? {
    let (t_, p) = x?;
    if *t_ >= tl {
    repl.push((*t_, p.a))
    }
    }
    let mut m = Merkle::zero();
    for x in btree::rev_iter(&txn.txn, &channel, Some((&tl, None)))? {
    let (t_, mm) = x?;
    if t_ < &tl {
    m = (&mm.b).into();
    break;
    }
    }
    for (t_, p) in repl.iter() {
    debug!("del_changes {:?} {:?}", t_, p);
    btree::del(&mut txn.txn, channel, t_, None)?;
    if *t_ > tl || !del {
    m = m.next(p);
    btree::put(&mut txn.txn, channel, t_, &Pair { a: *p, b: m.into() })?;
    }
    }
    Ok(())
    }
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1853
    [5.3643][6.52484:52526](),[6.562319][6.52484:52526]()
    ) -> Result<bool, Self::GraphError> {
    [5.3643]
    [6.99033]
    ) -> Result<bool, TxnErr<Self::GraphError>> {
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1865
    [5.3661][5.3661:3735]()
    btree::put(&mut self.txn, &mut remote.tags, &k.into(), &())?;
    [5.3661]
    [5.3735]
    self.put_tags(&mut remote.tags, k, &v.1)?;
  • replacement in libpijul/src/pristine/sanakirja.rs at line 1874
    [6.52619][6.52619:52661]()
    ) -> Result<bool, Self::GraphError> {
    [6.52619]
    [6.99077]
    ) -> Result<bool, TxnErr<Self::GraphError>> {
  • edit in libpijul/src/pristine/mod.rs at line 677
    [6.605760]
    [6.605760]
    table!(remotetags);
  • edit in libpijul/src/pristine/mod.rs at line 682
    [6.103300]
    [6.605897]
    cursor!(remotetags, L64, Pair<SerializedMerkle, SerializedMerkle>);
    rev_cursor!(remotetags, L64, Pair<SerializedMerkle, SerializedMerkle>);
  • edit in libpijul/src/pristine/mod.rs at line 719
    [24.36994]
    [6.59531]
    fn last_remote_tag(
    &self,
    remote: &Self::Remotetags,
    ) -> Result<Option<(u64, &SerializedMerkle, &SerializedMerkle)>, TxnErr<Self::GraphError>>;
  • replacement in libpijul/src/pristine/mod.rs at line 1797
    [6.27347][6.27347:27411]()
    channel: &mut Self::Channel,
    t: ApplyTimestamp,
    [6.27347]
    [6.27429]
    channel: &mut Self::Tags,
    n: u64,
    m: &Merkle,
  • replacement in libpijul/src/pristine/mod.rs at line 1804
    [6.27513][6.27513:27577]()
    channel: &mut Self::Channel,
    t: ApplyTimestamp,
    [6.27513]
    [6.27577]
    channel: &mut Self::Tags,
    n: u64,
  • replacement in libpijul/src/pristine/mod.rs at line 1882
    [5.3962][6.74624:74665](),[6.638359][6.74624:74665]()
    ) -> Result<bool, Self::GraphError>;
    [5.3962]
    [6.638397]
    ) -> Result<bool, TxnErr<Self::GraphError>>;
  • replacement in libpijul/src/pristine/mod.rs at line 1888
    [6.74758][6.74758:74799]()
    ) -> Result<bool, Self::GraphError>;
    [6.74758]
    [6.638497]
    ) -> Result<bool, TxnErr<Self::GraphError>>;
  • edit in libpijul/src/pristine/merkle.rs at line 33
    [4.195]
    [4.195]
    }
    }
    }
    impl From<&super::Hash> for curve25519_dalek::scalar::Scalar {
    fn from(h: &super::Hash) -> Self {
    match h {
    super::Hash::Blake3(h) => {
    curve25519_dalek::scalar::Scalar::from_bytes_mod_order(*h)
    }
    _ => unreachable!(),
  • edit in libpijul/src/pristine/merkle.rs at line 48
    [6.639295]
    [6.639295]
    impl From<&super::SerializedHash> for curve25519_dalek::scalar::Scalar {
    fn from(h: &super::SerializedHash) -> Self {
    let h: super::Hash = h.into();
    (&h).into()
    }
    }
    impl From<&Merkle> for curve25519_dalek::scalar::Scalar {
    fn from(h: &Merkle) -> Self {
    match *h {
    Merkle::Ed25519(h) => {
    let h = h.compress();
    curve25519_dalek::scalar::Scalar::from_bytes_mod_order(*h.as_bytes())
    }
    }
    }
    }
    impl From<&super::SerializedMerkle> for curve25519_dalek::scalar::Scalar {
    fn from(h: &super::SerializedMerkle) -> Self {
    let h: Merkle = h.into();
    (&h).into()
    }
    }
  • replacement in libpijul/src/pristine/merkle.rs at line 77
    [6.639392][6.639392:639442]()
    pub fn next(&self, h: &super::Hash) -> Self {
    [6.639392]
    [6.639442]
    pub fn next<S: Into<curve25519_dalek::scalar::Scalar>>(&self, h: S) -> Self {
  • replacement in libpijul/src/pristine/merkle.rs at line 80
    [6.639504][6.639504:639756]()
    let scalar = match *h {
    super::Hash::Blake3(h) => {
    curve25519_dalek::scalar::Scalar::from_bytes_mod_order(h)
    }
    _ => unreachable!(),
    };
    [6.639504]
    [6.639756]
    let scalar = h.into();