-
Notifications
You must be signed in to change notification settings - Fork 163
Use Key-value DB for DataStore and PinStore #439
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let db = kv_db.get_db(); | ||
|
||
match db.get(key.as_str()) { | ||
Ok(Some(_)) => return Ok(Some(mode.clone())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: PinMode
isn't Copy
, but it should be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very much agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Thank you very much @fetchadd! bors r+ |
Build succeeded: |
@fetchadd re: my review comments; I found a few things to fix, missing tests but I'll post a draft on thursday on my progress. |
This PR is for using key-value db like sled as DataStore and PinSotre, so that it is more efficient for pinning and easy to realize MFS.
The FsDatastore is inefficiency now, when checking a indirect pinned cid, all file in the FsDatastore will be visited and read, what more important is that it is hard to distinguish the data for pinning and the data for DataStore. The key-value db like sled will bring convenience and efficiency in the next work with its high efficiency and easy key/value operation. Leveldb may be the first choice of key-value dbs, but now there are no suitable rust leveldb crates; Sled is fast and simple, and it is usable on servers and phones from any C-compatible language.
This PR is the reopen of PR434. For there is some verbose commits like "replaceing leveldb with sled", the master branch of fetchadd/rust-ipfs in the PR434 is deprecated. Now the same changes are applied to the staging branch which is synced with the master of rust-ipfs/rust-ipfs. So Thanks for the PR of fetchadd/rust-ipfs from @koivunej which uses mutex to work around init(&self) and unsafe, but as the master is deprecated, I can only copy the code to staging branch.
Accorrding to the review from @ koivunej in PR434, the
pinstore_interface_tests
is added to KvDataStore, and now all tests are passed.Closes #434.