@@ -74,35 +74,36 @@ pub const MONITOR_UPDATING_PERSISTER_PREPEND_SENTINEL: &[u8] = &[0xFF; 2];
74
74
/// Provides an interface that allows storage and retrieval of persisted values that are associated
75
75
/// with given keys.
76
76
///
77
- /// In order to avoid collisions the key space is segmented based on the given `namespace`s and
78
- /// `sub_namespace`s. Implementations of this trait are free to handle them in different ways, as
79
- /// long as per-namespace key uniqueness is asserted.
77
+ /// In order to avoid collisions the key space is segmented based on the given `primary_namespace`s
78
+ /// and `sub_namespace`s. Implementations of this trait are free to handle them in different ways,
79
+ /// as long as per-namespace key uniqueness is asserted.
80
80
///
81
81
/// Keys and namespaces are required to be valid ASCII strings in the range of
82
82
/// [`KVSTORE_NAMESPACE_KEY_ALPHABET`] and no longer than [`KVSTORE_NAMESPACE_KEY_MAX_LEN`]. Empty
83
- /// namespaces and sub-namespaces (`""`) are assumed to be a valid, however, if `namespace` is
84
- /// empty, `sub_namespace` is required to be empty, too. This means that concerns should always be
85
- /// separated by namespace first, before sub-namespaces are used. While the number of namespaces
86
- /// will be relatively small and is determined at compile time, there may be many sub-namespaces
87
- /// per namespace. Note that per-namespace uniqueness needs to also hold for keys *and*
88
- /// namespaces/sub-namespaces in any given namespace/sub-namespace , i.e., conflicts between keys
89
- /// and equally named namespaces/sub-namespaces must be avoided.
83
+ /// primary namespaces and sub-namespaces (`""`) are assumed to be a valid, however, if
84
+ /// `primary_namespace` is empty, `sub_namespace` is required to be empty, too. This means that
85
+ /// concerns should always be separated by primary namespace first, before sub-namespaces are used.
86
+ /// While the number of primary namespaces will be relatively small and is determined at compile
87
+ /// time, there may be many sub-namespaces per primary namespace. Note that per-namespace
88
+ /// uniqueness needs to also hold for keys *and* namespaces in any given namespace, i.e., conflicts
89
+ /// between keys and equally named primary- namespaces/sub-namespaces must be avoided.
90
90
///
91
91
/// **Note:** Users migrating custom persistence backends from the pre-v0.0.117 `KVStorePersister`
92
- /// interface can use a concatenation of `[{namespace }/[{sub_namespace}/]]{key}` to recover a `key` compatible with the
93
- /// data model previously assumed by `KVStorePersister::persist`.
92
+ /// interface can use a concatenation of `[{primary_namespace }/[{sub_namespace}/]]{key}` to recover
93
+ /// a `key` compatible with the data model previously assumed by `KVStorePersister::persist`.
94
94
pub trait KVStore {
95
- /// Returns the data stored for the given `namespace `, `sub_namespace`, and `key`.
95
+ /// Returns the data stored for the given `primary_namespace `, `sub_namespace`, and `key`.
96
96
///
97
97
/// Returns an [`ErrorKind::NotFound`] if the given `key` could not be found in the given
98
- /// `namespace ` and `sub_namespace`.
98
+ /// `primary_namespace ` and `sub_namespace`.
99
99
///
100
100
/// [`ErrorKind::NotFound`]: io::ErrorKind::NotFound
101
- fn read ( & self , namespace : & str , sub_namespace : & str , key : & str ) -> Result < Vec < u8 > , io:: Error > ;
101
+ fn read ( & self , primary_namespace : & str , sub_namespace : & str , key : & str ) -> Result < Vec < u8 > , io:: Error > ;
102
102
/// Persists the given data under the given `key`.
103
103
///
104
- /// Will create the given `namespace` and `sub_namespace` if not already present in the store.
105
- fn write ( & self , namespace : & str , sub_namespace : & str , key : & str , buf : & [ u8 ] ) -> Result < ( ) , io:: Error > ;
104
+ /// Will create the given `primary_namespace` and `sub_namespace` if not already present in the
105
+ /// store.
106
+ fn write ( & self , primary_namespace : & str , sub_namespace : & str , key : & str , buf : & [ u8 ] ) -> Result < ( ) , io:: Error > ;
106
107
/// Removes any data that had previously been persisted under the given `key`.
107
108
///
108
109
/// If the `lazy` flag is set to `true`, the backend implementation might choose to lazily
@@ -115,14 +116,16 @@ pub trait KVStore {
115
116
/// potentially get lost on crash after the method returns. Therefore, this flag should only be
116
117
/// set for `remove` operations that can be safely replayed at a later time.
117
118
///
118
- /// Returns successfully if no data will be stored for the given `namespace`, `sub_namespace`, and
119
- /// `key`, independently of whether it was present before its invokation or not.
120
- fn remove ( & self , namespace : & str , sub_namespace : & str , key : & str , lazy : bool ) -> Result < ( ) , io:: Error > ;
121
- /// Returns a list of keys that are stored under the given `sub_namespace` in `namespace`.
119
+ /// Returns successfully if no data will be stored for the given `primary_namespace`,
120
+ /// `sub_namespace`, and `key`, independently of whether it was present before its invokation
121
+ /// or not.
122
+ fn remove ( & self , primary_namespace : & str , sub_namespace : & str , key : & str , lazy : bool ) -> Result < ( ) , io:: Error > ;
123
+ /// Returns a list of keys that are stored under the given `sub_namespace` in
124
+ /// `primary_namespace`.
122
125
///
123
126
/// Returns the keys in arbitrary order, so users requiring a particular order need to sort the
124
- /// returned keys. Returns an empty list if `namespace ` or `sub_namespace` is unknown.
125
- fn list ( & self , namespace : & str , sub_namespace : & str ) -> Result < Vec < String > , io:: Error > ;
127
+ /// returned keys. Returns an empty list if `primary_namespace ` or `sub_namespace` is unknown.
128
+ fn list ( & self , primary_namespace : & str , sub_namespace : & str ) -> Result < Vec < String > , io:: Error > ;
126
129
}
127
130
128
131
/// Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk.
@@ -299,7 +302,7 @@ where
299
302
///
300
303
/// Each [`ChannelMonitorUpdate`] is stored in a dynamic sub-namespace, as follows:
301
304
///
302
- /// - namespace: [`CHANNEL_MONITOR_UPDATE_PERSISTENCE_NAMESPACE`]
305
+ /// - primary- namespace: [`CHANNEL_MONITOR_UPDATE_PERSISTENCE_NAMESPACE`]
303
306
/// - sub-namespace: [the monitor's encoded outpoint name]
304
307
///
305
308
/// Under that sub-namespace, each update is stored with a number string, like `21`, which
@@ -314,7 +317,7 @@ where
314
317
///
315
318
/// `[CHANNEL_MONITOR_PERSISTENCE_NAMESPACE]/deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef_1`
316
319
///
317
- /// Updates would be stored as follows (with `/` delimiting namespace/sub-namespace/key):
320
+ /// Updates would be stored as follows (with `/` delimiting primary- namespace/sub-namespace/key):
318
321
///
319
322
/// ```text
320
323
/// [CHANNEL_MONITOR_UPDATE_PERSISTENCE_NAMESPACE]/deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef_1/1
0 commit comments