feat: schema v2 with the kept column and contact history, migrated at open

This commit is contained in:
randogoth 2026-09-29 00:16:54 +03:00
parent 21931c38d4
commit 96d2412370
3 changed files with 161 additions and 16 deletions

View file

@ -213,6 +213,11 @@ pub fn trust_key(
Some((old, _)) if ct_eq(&old, &identity) => Ok((identity, TrustChange::None)),
Some((old, verified)) => {
if walk_chain(&addr.user, &old, &identity, &chain) {
// The displaced key is the only local record that this
// contact rotated, so it is kept (sec 8) before the current
// one moves on. `until` is milliseconds, the unit the export
// format carries.
store.save_history(&addr.short(), &old, crate::store::now() * 1000)?;
store.save_contact(&addr.short(), &identity, verified)?;
Ok((identity, TrustChange::Rotated))
} else {
@ -667,7 +672,7 @@ pub fn fetch_with(
// if we deleted it locally in the meantime (sec 10).
if !store.seen(&mid)? {
let requests_tier = flags & FLAG_REQUESTS != 0;
store.store_inbox(&mid, &envelope, received_at, requests_tier)?;
store.store_inbox(&mid, &envelope, received_at, requests_tier, opts.keep)?;
learn_token(store, &opened)?;
summary.stored += 1;
}