libp2p / libp2p/rust-libp2p

Redesign `RecordStore` API / interaction

Open
#3,035 13 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Description

Currently, RecordStore trait returns Result only for put and add_provider operations. However, custom implementations (for example DB-based) could return errors on each operation.

I wonder whether it's possible to change this trait and add Result on each operation to make the trait more consistent with use cases.

Motivation

This change will allow handling errors for implementations in an idiomatic way.

Current Implementation

    /// Gets a record from the store, given its key.
    fn get(&'a self, k: &Key) -> Option<Cow<'_, Record>>;

    /// Puts a record into the store.
    fn put(&'a mut self, r: Record) -> Result<()>;

    /// Removes the record with the given key from the store.
    fn remove(&'a mut self, k: &Key);

    /// Gets an iterator over all (value-) records currently stored.
    fn records(&'a self) -> Self::RecordsIter;

.....

Are you planning to do it yourself in a pull request?

Not this time. This change could affect inner Kademlia error handling.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the RecordStore trait and inspect its current operations and the inner Kademlia error-handling paths that depend on it. Determine which operations need Result returns and assess the impact on custom implementations and callers; done requires an agreed API redesign with consistent error propagation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
distributed-systems, networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.