5MRZLKBHOFFUAJELWL34XILG2XVWPUEHOFPDXBK5ASCO6H26MBFAC
C267PHOH3QJBSBEWQB3J7PPOOXIUKM3DIIZIPLHPU4D5OXRCGLZAC
7ZROQSSN2M3LW6ASYMM6DPR5AERWV4K4TKWKEBKTCEJPMIJAHHXQC
RIAA2QKFQM2BIDU3KIUXI5VYIUKTIHD2BURROGY6UXNJ7KRPY4IQC
RM225IDQR36MNBMN7OT2R562M4FUD6L34RY7A3WDBBETZIIDKZ5AC
QL6K2ZM35B3NIXEMMCJWUSFXOBQHAGXRDMO7ID5DCKTJH4QJVY7QC
IVLLXQ5ZWZDKHO4TNQG3TPXN34H6Y2WXPAGSO4PWCYNSKUZWOEJQC
SXEYMYF7P4RZMZ46WPL4IZUTSQ2ATBWYZX7QNVMS3SGOYXYOHAGQC
A3RM526Y7LUXNYW4TL56YKQ5GVOK2R5D7JJVTSQ6TT5MEXIR6YAAC
YN63NUZO4LVJ7XPMURDULTXBVJKW5MVCTZ24R7Z52QMHO3HPDUVQC
GHO6DWPILBBTL6CVZKERJBTFL3EY6ZT4YM4E5R4S6YPGVFKFHCVAC
AAXP2534BWX2ZUDZZHUMLYDBMGFGUH32CNRA3KOLER3JKOIJUZLAC
CCLLB7OIFNFYJZTG3UCI7536TOCWSCSXR67VELSB466R24WLJSDAC
FXEDPLRI7PXLDXV634ZA6D5Q3ZWG3ESTKJTMRPJ4MAHI7PKU3M6AC
I52XSRUH5RVHQBFWVMAQPTUSPAJ4KNVID2RMI3UGCVKFLYUO6WZAC
type TagsCursor =
::sanakirja::btree::cursor::Cursor<L64, (), P<L64, ()>>;
type TagsCursor = ::sanakirja::btree::cursor::Cursor<
L64,
Pair<SerializedMerkle, SerializedMerkle>,
P<L64, Pair<SerializedMerkle, SerializedMerkle>>,
>;
) -> Result<
super::Cursor<Self, &Self, Self::TagsCursor, L64, ()>,
TxnErr<Self::GraphError>,
> {
) -> Result<super::Cursor<Self, &Self, Self::TagsCursor, L64, ()>, TxnErr<Self::GraphError>>
{
) -> Result<
super::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>,
TxnErr<Self::GraphError>,
> {
) -> Result<super::RevCursor<Self, &Self, Self::TagsCursor, L64, ()>, TxnErr<Self::GraphError>>
{
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>>,
>;
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)
}
}
btree::put(&mut self.txn, &mut channel.tags, &t.into(), &())?;
Ok(())
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(())
}
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(())
}
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()
}
}