Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

implement the RemovePeer method #174

Merged
merged 3 commits into from
Dec 2, 2021
Merged

implement the RemovePeer method #174

merged 3 commits into from
Dec 2, 2021

Conversation

marten-seemann
Copy link
Contributor

@marten-seemann marten-seemann commented Oct 23, 2021

Depends on #173.

This PR doesn't fully work yet, removing from the dsPeerMetaData doesn't work (see comment below).

@@ -71,3 +71,7 @@ func (pm *dsPeerMetadata) Put(p peer.ID, key string, val interface{}) error {
}
return pm.ds.Put(k, buf.Bytes())
}

func (pm *dsPeerMetadata) RemovePeer(p peer.ID) {
pm.ds.Delete(pmBase.ChildString(base32.RawStdEncoding.EncodeToString([]byte(p))))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. When Putting, we generate a ds.Key based on the peer ID and the key. Without the key, we have no way of getting back (and deleting) that entry. @vyzo, any idea what to do here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to change the way we generate the ds.Key so that we only use the peer ID.
Why were we using the key in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it was implemented so we can store multiple key-value pairs for the same peer. How else would we implement this?

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo fixing the key issue in pstoreds.

@@ -71,3 +71,7 @@ func (pm *dsPeerMetadata) Put(p peer.ID, key string, val interface{}) error {
}
return pm.ds.Put(k, buf.Bytes())
}

func (pm *dsPeerMetadata) RemovePeer(p peer.ID) {
pm.ds.Delete(pmBase.ChildString(base32.RawStdEncoding.EncodeToString([]byte(p))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to change the way we generate the ds.Key so that we only use the peer ID.
Why were we using the key in the first place?

@vyzo
Copy link
Contributor

vyzo commented Oct 23, 2021 via email

@vyzo
Copy link
Contributor

vyzo commented Oct 23, 2021 via email

@BigLep BigLep requested a review from a team October 24, 2021 04:30
@marten-seemann marten-seemann force-pushed the remove-peer branch 2 times, most recently from 6ba12a1 to 26a66ed Compare October 24, 2021 09:55
@marten-seemann
Copy link
Contributor Author

Fixed. We're now querying the keystore for the key prefix and remove all entries.

go.mod Outdated
@@ -12,7 +12,7 @@ require (
github.com/ipfs/go-ds-leveldb v0.4.2
github.com/ipfs/go-log v1.0.5
github.com/libp2p/go-buffer-pool v0.0.2
github.com/libp2p/go-libp2p-core v0.8.6
github.com/libp2p/go-libp2p-core v0.11.1-0.20211023074228-0b9196b76a61
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want a master commit or release tag for this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants