diff options
-rw-r--r-- | examples/guide-the-keystore.rs | 10 | ||||
-rw-r--r-- | ffi/include/sequoia/store.h | 74 | ||||
-rw-r--r-- | ffi/lang/python/sequoia/store.py | 37 | ||||
-rw-r--r-- | ffi/lang/python/tests/test_store.py | 12 | ||||
-rw-r--r-- | ffi/src/store.rs | 126 | ||||
-rw-r--r-- | store/src/backend/log.rs | 44 | ||||
-rw-r--r-- | store/src/backend/mod.rs | 136 | ||||
-rw-r--r-- | store/src/lib.rs | 339 | ||||
-rw-r--r-- | store/src/store_protocol.capnp | 12 | ||||
-rw-r--r-- | store/tests/ipc-policy.rs | 10 | ||||
-rw-r--r-- | tool/src/commands/decrypt.rs | 8 | ||||
-rw-r--r-- | tool/src/commands/mod.rs | 24 | ||||
-rw-r--r-- | tool/src/sq-usage.rs | 72 | ||||
-rw-r--r-- | tool/src/sq.rs | 82 | ||||
-rw-r--r-- | tool/src/sq_cli.rs | 34 |
15 files changed, 511 insertions, 509 deletions
diff --git a/examples/guide-the-keystore.rs b/examples/guide-the-keystore.rs index 8aff153e..f818137a 100644 --- a/examples/guide-the-keystore.rs +++ b/examples/guide-the-keystore.rs @@ -44,14 +44,14 @@ fn main() { // Parse TPK. let tpk = openpgp::TPK::from_bytes(tpk).unwrap(); - // Open a store. - let store = - store::Store::open(&ctx, store::REALM_CONTACTS, "default").unwrap(); + // Open a mapping. + let mapping = + store::Mapping::open(&ctx, store::REALM_CONTACTS, "default").unwrap(); // Store the TPK. - store.import("Ἀριστοτέλης", &tpk).unwrap(); + mapping.import("Ἀριστοτέλης", &tpk).unwrap(); // Now let's get it back. - let tpk_ = store.lookup("Ἀριστοτέλης").unwrap().tpk().unwrap(); + let tpk_ = mapping.lookup("Ἀριστοτέλης").unwrap().tpk().unwrap(); assert_eq!(tpk.fingerprint(), tpk_.fingerprint()); } diff --git a/ffi/include/sequoia/store.h b/ffi/include/sequoia/store.h index 47b581b1..50abc67a 100644 --- a/ffi/include/sequoia/store.h +++ b/ffi/include/sequoia/store.h @@ -14,19 +14,19 @@ const char *SQ_REALM_CONTACTS = "org.sequoia-pgp.contacts"; const char *SQ_REALM_SOFTWARE_UPDATES = "org.sequoia-pgp.software-updates"; /*/ -/// A public key store. +/// A public key mapping. /*/ -typedef struct sq_store *sq_store_t; +typedef struct sq_mapping *sq_mapping_t; /*/ -/// Frees a sq_store_t. +/// Frees a sq_mapping_t. /*/ -void sq_store_free (sq_store_t store); +void sq_mapping_free (sq_mapping_t mapping); /*/ -/// Represents an entry in a Store. +/// Represents an entry in a Mapping. /// -/// Stores map labels to TPKs. A `Binding` represents a pair in this +/// Mappings map labels to TPKs. A `Binding` represents a pair in this /// relation. We make this explicit because we associate metadata /// with these pairs. /*/ @@ -38,7 +38,7 @@ typedef struct sq_binding *sq_binding_t; void sq_binding_free (sq_binding_t binding); /*/ -/// Represents a key in a store. +/// Represents a key in a mapping. /// /// A `Key` is a handle to a stored TPK. We make this explicit /// because we associate metadata with TPKs. @@ -60,11 +60,11 @@ struct sq_log { uint64_t timestamp; /*/ - /// Relates the entry to a store. + /// Relates the entry to a mapping. /// /// May be `NULL`. /*/ - sq_store_t store; + sq_mapping_t mapping; /*/ /// Relates the entry to a binding. @@ -159,31 +159,31 @@ typedef struct sq_stats *sq_stats_t; void sq_stats_free (sq_stats_t stats); /*/ -/// Iterates over stores. +/// Iterates over mappings. /*/ -typedef struct sq_store_iter *sq_store_iter_t; +typedef struct sq_mapping_iter *sq_mapping_iter_t; /*/ -/// Returns the next store. +/// Returns the next mapping. /// /// Returns `NULL` on exhaustion. If `realmp` is not `NULL`, the -/// stores realm is stored there. If `namep` is not `NULL`, the -/// stores name is stored there. If `policyp` is not `NULL`, the -/// stores network policy is stored there. +/// mapping's realm is stored there. If `namep` is not `NULL`, the +/// mapping's name is stored there. If `policyp` is not `NULL`, the +/// mapping's network policy is stored there. /*/ -sq_store_t sq_store_iter_next (sq_store_iter_t iter, +sq_mapping_t sq_mapping_iter_next (sq_mapping_iter_t iter, char **realmp, char **namep, uint8_t *policyp); /*/ -/// Frees a sq_store_iter_t. +/// Frees a sq_mapping_iter_t. /*/ -void sq_store_iter_free (sq_store_iter_t iter); +void sq_mapping_iter_free (sq_mapping_iter_t iter); /*/ -/// Iterates over bindings in a store. +/// Iterates over bindings in a mapping. /*/ typedef struct sq_binding_iter *sq_binding_iter_t; @@ -250,36 +250,36 @@ sq_log_iter_t sq_store_server_log (sq_context_t ctx); sq_key_iter_t sq_store_list_keys (sq_context_t ctx); /*/ -/// Opens a store. +/// Opens a mapping. /// -/// Opens a store with the given name in the given realm. If the -/// store does not exist, it is created. Stores are handles for +/// Opens a mapping with the given name in the given realm. If the +/// mapping does not exist, it is created. Mappings are handles for /// objects maintained by a background service. The background /// service associates state with this name. /// -/// The store updates TPKs in compliance with the network policy -/// of the context that created the store in the first place. -/// Opening the store with a different network policy is +/// The mapping updates TPKs in compliance with the network policy +/// of the context that created the mapping in the first place. +/// Opening the mapping with a different network policy is /// forbidden. /*/ -sq_store_t sq_store_open (sq_context_t ctx, const char *realm, const char *name); +sq_mapping_t sq_mapping_open (sq_context_t ctx, const char *realm, const char *name); /*/ -/// Adds a key identified by fingerprint to the store. +/// Adds a key identified by fingerprint to the mapping. /*/ -sq_binding_t sq_store_add (sq_context_t ctx, sq_store_t store, +sq_binding_t sq_mapping_add (sq_context_t ctx, sq_mapping_t mapping, const char *label, pgp_fingerprint_t fp); /*/ -/// Imports a key into the store. +/// Imports a key into the mapping. /*/ -pgp_tpk_t sq_store_import (sq_context_t ctx, sq_store_t store, +pgp_tpk_t sq_mapping_import (sq_context_t ctx, sq_mapping_t mapping, const char *label, pgp_tpk_t tpk); /*/ /// Returns the binding for the given label. /*/ -sq_binding_t sq_store_lookup (sq_context_t ctx, sq_store_t store, +sq_binding_t sq_mapping_lookup (sq_context_t ctx, sq_mapping_t mapping, const char *label); /*/ @@ -293,21 +293,21 @@ sq_key_t sq_store_lookup_by_keyid (sq_context_t ctx, pgp_keyid_t keyid); sq_key_t sq_store_lookup_by_subkeyid (sq_context_t ctx, pgp_keyid_t keyid); /*/ -/// Deletes this store. +/// Deletes this mapping. /// -/// Consumes `store`. Returns != 0 on error. +/// Consumes `mapping`. Returns != 0 on error. /*/ -pgp_status_t sq_store_delete (sq_store_t store); +pgp_status_t sq_mapping_delete (sq_mapping_t mapping); /*/ /// Lists all bindings. /*/ -sq_binding_iter_t sq_store_iter (sq_context_t ctx, sq_store_t store); +sq_binding_iter_t sq_mapping_iter (sq_context_t ctx, sq_mapping_t mapping); /*/ -/// Lists all log entries related to this store. +/// Lists all log entries related to this mapping. /*/ -sq_log_iter_t sq_store_log (sq_context_t ctx, sq_store_t store); +sq_log_iter_t sq_mapping_log (sq_context_t ctx, sq_mapping_t mapping); /*/ /// Returns the `sq_stats_t` of this binding. diff --git a/ffi/lang/python/sequoia/store.py b/ffi/lang/python/sequoia/store.py index c9ce84e8..6cf4347b 100644 --- a/ffi/lang/python/sequoia/store.py +++ b/ffi/lang/python/sequoia/store.py @@ -4,17 +4,9 @@ from .error import Error from .glue import _str, _static_str, SQObject, sq_iterator, sq_time from .openpgp import Fingerprint, TPK -class Store(SQObject): - _del = lib.sq_store_free - - # Keys used for communications. - REALM_CONTACTS = _static_str(lib.SQ_REALM_CONTACTS) - - # Keys used for signing software updates. - REALM_SOFTWARE_UPDATES = _static_str(lib.SQ_REALM_SOFTWARE_UPDATES) - +class Store(object): @classmethod - def server_log(cls, ctx): + def log(cls, ctx): yield from sq_iterator( ffi.gc( lib.sq_store_server_log(ctx.ref()), @@ -39,30 +31,39 @@ class Store(SQObject): lib.sq_key_iter_free), next_fn) +class Mapping(SQObject): + _del = lib.sq_mapping_free + + # Keys used for communications. + REALM_CONTACTS = _static_str(lib.SQ_REALM_CONTACTS) + + # Keys used for signing software updates. + REALM_SOFTWARE_UPDATES = _static_str(lib.SQ_REALM_SOFTWARE_UPDATES) + @classmethod def open(cls, ctx, realm=REALM_CONTACTS, name="default"): - return Store(lib.sq_store_open(ctx.ref(), realm.encode(), name.encode()), context=ctx) + return Mapping(lib.sq_mapping_open(ctx.ref(), realm.encode(), name.encode()), context=ctx) def add(self, label, fingerprint): - return Binding(lib.sq_store_add(self.context().ref(), self.ref(), + return Binding(lib.sq_mapping_add(self.context().ref(), self.ref(), label.encode(), fingerprint.ref()), context=self.context()) def import_(self, label, tpk): - return TPK(lib.sq_store_import(self.context().ref(), self.ref(), + return TPK(lib.sq_mapping_import(self.context().ref(), self.ref(), label.encode(), tpk.ref()), context=self.context()) def lookup(self, label): - return Binding(lib.sq_store_lookup(self.context().ref(), self.ref(), + return Binding(lib.sq_mapping_lookup(self.context().ref(), self.ref(), label.encode()), self.context()) def delete(self): - if lib.sq_store_delete(self.ref()): + if lib.sq_mapping_delete(self.ref()): raise Error._last(self.context()) - super(Store, self)._delete(skip_free=True) + super(Mapping, self)._delete(skip_free=True) def iter(self): def next_fn(i): @@ -78,14 +79,14 @@ class Store(SQObject): yield from sq_iterator( ffi.gc( - lib.sq_store_iter(self.context().ref(), self.ref()), + lib.sq_mapping_iter(self.context().ref(), self.ref()), lib.sq_binding_iter_free), next_fn) def log(self): yield from sq_iterator( ffi.gc( - lib.sq_store_log(self.context().ref(), self.ref()), + lib.sq_mapping_log(self.context().ref(), self.ref()), lib.sq_log_iter_free), lib.sq_log_iter_next, lambda x: Log(x, context=self.context())) diff --git a/ffi/lang/python/tests/test_store.py b/ffi/lang/python/tests/test_store.py index 454afb7d..7b06cc1a 100644 --- a/ffi/lang/python/tests/test_store.py +++ b/ffi/lang/python/tests/test_store.py @@ -1,18 +1,18 @@ -from sequoia.prelude import Context, Store, Fingerprint +from sequoia.prelude import Context, Store, Mapping, Fingerprint def test_open(): c = Context(ephemeral=True) - Store.open(c) + Mapping.open(c) def test_add(): c = Context(ephemeral=True) - s = Store.open(c) + s = Mapping.open(c) fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE") s.add("Ἀριστοτέλης", fp) def test_iterate(): c = Context(ephemeral=True) - s = Store.open(c) + s = Mapping.open(c) fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE") s.add("Ἀριστοτέλης", fp) l = list(s.iter()) @@ -24,14 +24,14 @@ def test_iterate(): def test_logs(): c = Context(ephemeral=True) - s = Store.open(c) + s = Mapping.open(c) fp = Fingerprint.from_hex("7DCA58B54EB143169DDEE15F247F6DABC84914FE") b = s.add("Ἀριστοτέλης", fp) l = list(s.iter()) assert len(l) == 1 # global logs - logs = list(Store.server_log(c)) + logs = list(Store.log(c)) assert len(logs) > 0 # per store logs diff --git a/ffi/src/store.rs b/ffi/src/store.rs index 9941044f..bdd59c53 100644 --- a/ffi/src/store.rs +++ b/ffi/src/store.rs @@ -29,7 +29,7 @@ use std::ptr; extern crate sequoia_openpgp as openpgp; use sequoia_store::{ - self, Store, StoreIter, Binding, BindingIter, Key, KeyIter, LogIter, Pool, + self, Mapping, MappingIter, Binding, BindingIter, Key, KeyIter, LogIter, Pool, }; use super::error::Status; @@ -43,33 +43,33 @@ use crate::MoveIntoRaw; use crate::MoveResultIntoRaw; use crate::Maybe; -/// Lists all stores with the given prefix. +/// Lists all mappings with the given prefix. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_list_stores(ctx: *mut Context, +fn sq_store_list_mappings(ctx: *mut Context, realm_prefix: *const c_char) - -> *mut StoreIter { + -> *mut MappingIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let realm_prefix = ffi_param_cstr!(realm_prefix).to_string_lossy(); - ffi_try_box!(Store::list(&ctx.c, &realm_prefix)) + ffi_try_box!(Mapping::list(&ctx.c, &realm_prefix)) } -/// Returns the next store. +/// Returns the next mapping. /// /// Returns `NULL` on exhaustion. If `realmp` is not `NULL`, the -/// stores realm is stored there. If `namep` is not `NULL`, the -/// stores name is stored there. If `policyp` is not `NULL`, the -/// stores network policy is stored there. +/// mapping's realm is stored there. If `namep` is not `NULL`, the +/// mapping's name is stored there. If `policyp` is not `NULL`, the +/// mapping's network policy is stored there. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_iter_next(iter: *mut StoreIter, +fn sq_mapping_iter_next(iter: *mut MappingIter, realmp: Option<&mut *mut c_char>, namep: Option<&mut *mut c_char>, policyp: Option<&mut u8>) - -> *mut Store { + -> *mut Mapping { let iter = ffi_param_ref_mut!(iter); match iter.next() { - Some((realm, name, policy, store)) => { + Some((realm, name, policy, mapping)) => { if realmp.is_some() { *realmp.unwrap() = ffi_return_maybe_string!(realm); } @@ -82,15 +82,15 @@ fn sq_store_iter_next(iter: *mut StoreIter, *policyp.unwrap() = (&policy).into(); } - box_raw!(store) + box_raw!(mapping) }, None => ptr::null_mut(), } } -/// Frees a sq_store_iter_t. +/// Frees a sq_mapping_iter_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_iter_free(iter: Option<&mut StoreIter>) { +fn sq_mapping_iter_free(iter: Option<&mut MappingIter>) { ffi_free!(iter) } @@ -100,7 +100,7 @@ fn sq_store_list_keys(ctx: *mut Context) -> *mut KeyIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - ffi_try_box!(Store::list_keys(&ctx.c)) + ffi_try_box!(Pool::list_keys(&ctx.c)) } /// Lists all log entries. @@ -109,7 +109,7 @@ fn sq_store_server_log(ctx: *mut Context) -> *mut LogIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - ffi_try_box!(Store::server_log(&ctx.c)) + ffi_try_box!(Pool::server_log(&ctx.c)) } /// Returns the next key. @@ -160,7 +160,7 @@ fn sq_log_iter_next(iter: *mut LogIter) -> *mut Log { box_raw!(Log{ timestamp: e.timestamp.sec as u64, - store: maybe_box_raw!(e.store), + mapping: maybe_box_raw!(e.mapping), binding: maybe_box_raw!(e.binding), key: maybe_box_raw!(e.key), slug: ffi_return_string!(&e.slug), @@ -178,80 +178,80 @@ fn sq_log_iter_free(iter: Option<&mut LogIter>) { ffi_free!(iter) } -/// Opens a store. +/// Opens a mapping. /// -/// Opens a store with the given name. If the store does not -/// exist, it is created. Stores are handles for objects +/// Opens a mapping with the given name. If the mapping does not +/// exist, it is created. Mappings are handles for objects /// maintained by a background service. The background service /// associates state with this name. /// -/// The store updates TPKs in compliance with the network policy -/// of the context that created the store in the first place. -/// Opening the store with a different network policy is +/// The mapping updates TPKs in compliance with the network policy +/// of the context that created the mapping in the first place. +/// Opening the mapping with a different network policy is /// forbidden. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_open(ctx: *mut Context, +fn sq_mapping_open(ctx: *mut Context, realm: *const c_char, name: *const c_char) - -> *mut Store { + -> *mut Mapping { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let realm = ffi_param_cstr!(realm).to_string_lossy(); let name = ffi_param_cstr!(name).to_string_lossy(); - ffi_try_box!(Store::open(&ctx.c, &realm, &name)) + ffi_try_box!(Mapping::open(&ctx.c, &realm, &name)) } -/// Frees a sq_store_t. +/// Frees a sq_mapping_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_free(store: Option<&mut Store>) { - ffi_free!(store) +fn sq_mapping_free(mapping: Option<&mut Mapping>) { + ffi_free!(mapping) } -/// Adds a key identified by fingerprint to the store. +/// Adds a key identified by fingerprint to the mapping. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_add(ctx: *mut Context, - store: *const Store, +fn sq_mapping_add(ctx: *mut Context, + mapping: *const Mapping, label: *const c_char, fingerprint: *const Fingerprint) -> *mut Binding { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_ref!(store); + let mapping = ffi_param_ref!(mapping); let label = ffi_param_cstr!(label).to_string_lossy(); let fingerprint = fingerprint.ref_raw(); - ffi_try_box!(store.add(&label, fingerprint)) + ffi_try_box!(mapping.add(&label, fingerprint)) } -/// Imports a key into the store. +/// Imports a key into the mapping. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_import(ctx: *mut Context, - store: *const Store, +fn sq_mapping_import(ctx: *mut Context, + mapping: *const Mapping, label: *const c_char, tpk: *const TPK) -> Maybe<TPK> { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_ref!(store); + let mapping = ffi_param_ref!(mapping); let label = ffi_param_cstr!(label).to_string_lossy(); let tpk = tpk.ref_raw(); - store.import(&label, tpk).move_into_raw(Some(ctx.errp())) + mapping.import(&label, tpk).move_into_raw(Some(ctx.errp())) } /// Returns the binding for the given label. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_lookup(ctx: *mut Context, - store: *const Store, +fn sq_mapping_lookup(ctx: *mut Context, + mapping: *const Mapping, label: *const c_char) -> *mut Binding { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_ref!(store); + let mapping = ffi_param_ref!(mapping); let label = ffi_param_cstr!(label).to_string_lossy(); - ffi_try_box!(store.lookup(&label)) + ffi_try_box!(mapping.lookup(&label)) } /// Looks up a key in the common key pool by KeyID. @@ -278,35 +278,35 @@ fn sq_store_lookup_by_subkeyid(ctx: *mut Context, keyid: *const KeyID) ffi_try_box!(Pool::lookup_by_subkeyid(&ctx.c, keyid)) } -/// Deletes this store. +/// Deletes this mapping. /// -/// Consumes `store`. Returns != 0 on error. +/// Consumes `mapping`. Returns != 0 on error. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_delete(ctx: *mut Context, store: *mut Store) +fn sq_mapping_delete(ctx: *mut Context, mapping: *mut Mapping) -> Status { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_move!(store); + let mapping = ffi_param_move!(mapping); - ffi_try_status!(store.delete()) + ffi_try_status!(mapping.delete()) } /// Lists all bindings. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_iter(ctx: *mut Context, store: *const Store) +fn sq_mapping_iter(ctx: *mut Context, mapping: *const Mapping) -> *mut BindingIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_ref!(store); + let mapping = ffi_param_ref!(mapping); - ffi_try_box!(store.iter()) + ffi_try_box!(mapping.iter()) } /// Returns the next binding. /// /// Returns `NULL` on exhaustion. If `labelp` is not `NULL`, the -/// bindings label is stored there. If `fpp` is not `NULL`, the -/// bindings fingerprint is stored there. +/// bindings label is mappingd there. If `fpp` is not `NULL`, the +/// bindings fingerprint is mappingd there. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn sq_binding_iter_next(iter: *mut BindingIter, labelp: Option<&mut *mut c_char>, @@ -340,15 +340,15 @@ fn sq_binding_iter_free(iter: Option<&mut BindingIter>) { ffi_free!(iter) } -/// Lists all log entries related to this store. +/// Lists all log entries related to this mapping. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_store_log(ctx: *mut Context, store: *const Store) +fn sq_mapping_log(ctx: *mut Context, mapping: *const Mapping) -> *mut LogIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); - let store = ffi_param_ref!(store); + let mapping = ffi_param_ref!(mapping); - ffi_try_box!(store.log()) + ffi_try_box!(mapping.log()) } /// Frees a sq_binding_t. @@ -368,8 +368,8 @@ fn sq_key_free(key: Option<&mut Key>) { fn sq_log_free(log: Option<&mut Log>) { if let Some(log) = log { let log = unsafe { Box::from_raw(log) }; - if ! log.store.is_null() { - ffi_param_move!(log.store); + if ! log.mapping.is_null() { + ffi_param_move!(log.mapping); } if ! log.binding.is_null() { ffi_param_move!(log.binding); @@ -453,7 +453,7 @@ fn sq_binding_import(ctx: *mut Context, /// /// The current key is replaced with the new key `tpk`, even if /// they do not have the same fingerprint. If a key with the same -/// fingerprint as `tpk` is already in the store, is merged with +/// fingerprint as `tpk` is already in the mapping, is merged with /// `tpk` and normalized. The returned key contains all packets /// known to Sequoia, and should be used instead of `tpk`. /// @@ -627,10 +627,10 @@ pub struct Log { /// Records the time of the entry. pub timestamp: u64, - /// Relates the entry to a store. + /// Relates the entry to a mapping. /// /// May be `NULL`. - pub store: *mut Store, + pub mapping: *mut Mapping, /// Relates the entry to a binding. /// diff --git a/store/src/backend/log.rs b/store/src/backend/log.rs index a2ddcf4b..b853fa28 100644 --- a/store/src/backend/log.rs +++ b/store/src/backend/log.rs @@ -4,13 +4,13 @@ use rusqlite::{Connection, types::ToSql}; use super::{ ID, Timestamp, Rc, Result, node, - StoreServer, BindingServer, KeyServer, + MappingServer, BindingServer, KeyServer, Promise, capnp, capnp_rpc }; /// Models entries referring to other objects. pub struct Refers { - store: Option<ID>, + mapping: Option<ID>, binding: Option<ID>, key: Option<ID>, } @@ -18,12 +18,12 @@ pub struct Refers { impl Refers { /// Builds an empty object. pub fn to() -> Self { - Refers{store: None, binding: None, key: None} + Refers{mapping: None, binding: None, key: None} } - /// Makes log refer a store. - pub fn store(mut self, id: ID) -> Self { - self.store = Some(id); + /// Makes log refer a mapping. + pub fn mapping(mut self, id: ID) -> Self { + self.mapping = Some(id); self } @@ -59,10 +59,10 @@ fn log(c: &Rc<Connection>, refers: Refers, slug: &str, message: &str, error: Option<&str>) -> Result<ID> { c.execute("INSERT INTO log - (timestamp, level, store, binding, key, slug, message, error) + (timestamp, level, mapping, binding, key, slug, message, error) VALUES (?1, 0, ?2, ?3, ?4, ?5, ?6, ?7)", &[&Timestamp::now() as &ToSql, - &refers.store, &refers.binding, &refers.key, + &refers.mapping, &refers.binding, &refers.key, &slug, &message, &error])?; Ok(c.last_insert_rowid().into()) } @@ -70,7 +70,7 @@ fn log(c: &Rc<Connection>, refers: Refers, /// Selects log entries to iterate over. pub enum Selector { All, - Store(ID), + Mapping(ID), Binding(ID), Key(ID), } @@ -97,7 +97,7 @@ impl node::log_iter::Server for IterServer { let ( id, timestamp, - store, binding, key, + mapping, binding, key, slug, message, error ): ( ID, Timestamp, @@ -107,7 +107,7 @@ impl node::log_iter::Server for IterServer { Selector::All => self.c.query_row( "SELECT id, timestamp, - store, binding, key, + mapping, binding, key, |