@@ -60,10 +60,10 @@ type Peerstore interface {
6060 // PeerInfo returns a peer.PeerInfo struct for given peer.ID.
6161 // This is a small slice of the information Peerstore has on
6262 // that peer, useful to other services.
63- PeerInfo (peer.ID ) peer.AddrInfo
63+ PeerInfo (context. Context , peer.ID ) peer.AddrInfo
6464
6565 // Peers returns all of the peer IDs stored across all inner stores.
66- Peers () peer.IDSlice
66+ Peers (context. Context ) peer.IDSlice
6767}
6868
6969// PeerMetadata can handle values of any type. Serializing values is
@@ -77,47 +77,47 @@ type PeerMetadata interface {
7777 // Get / Put is a simple registry for other peer-related key/value pairs.
7878 // If we find something we use often, it should become its own set of
7979 // methods. This is a last resort.
80- Get (p peer.ID , key string ) (interface {}, error )
81- Put (p peer.ID , key string , val interface {}) error
80+ Get (ctx context. Context , p peer.ID , key string ) (interface {}, error )
81+ Put (ctx context. Context , p peer.ID , key string , val interface {}) error
8282
8383 // RemovePeer removes all values stored for a peer.
84- RemovePeer (peer.ID )
84+ RemovePeer (context. Context , peer.ID )
8585}
8686
8787// AddrBook holds the multiaddrs of peers.
8888type AddrBook interface {
8989 // AddAddr calls AddAddrs(p, []ma.Multiaddr{addr}, ttl)
90- AddAddr (p peer.ID , addr ma.Multiaddr , ttl time.Duration )
90+ AddAddr (context. Context , peer.ID , ma.Multiaddr , time.Duration )
9191
9292 // AddAddrs gives this AddrBook addresses to use, with a given ttl
9393 // (time-to-live), after which the address is no longer valid.
9494 // If the manager has a longer TTL, the operation is a no-op for that address
95- AddAddrs (p peer.ID , addrs []ma.Multiaddr , ttl time.Duration )
95+ AddAddrs (context. Context , peer.ID , []ma.Multiaddr , time.Duration )
9696
9797 // SetAddr calls mgr.SetAddrs(p, addr, ttl)
98- SetAddr (p peer.ID , addr ma.Multiaddr , ttl time.Duration )
98+ SetAddr (context. Context , peer.ID , ma.Multiaddr , time.Duration )
9999
100100 // SetAddrs sets the ttl on addresses. This clears any TTL there previously.
101101 // This is used when we receive the best estimate of the validity of an address.
102- SetAddrs (p peer.ID , addrs []ma.Multiaddr , ttl time.Duration )
102+ SetAddrs (context. Context , peer.ID , []ma.Multiaddr , time.Duration )
103103
104104 // UpdateAddrs updates the addresses associated with the given peer that have
105105 // the given oldTTL to have the given newTTL.
106- UpdateAddrs (p peer.ID , oldTTL time.Duration , newTTL time.Duration )
106+ UpdateAddrs (context. Context , peer.ID , time.Duration , time.Duration )
107107
108108 // Addrs returns all known (and valid) addresses for a given peer.
109- Addrs (p peer.ID ) []ma.Multiaddr
109+ Addrs (context. Context , peer.ID ) []ma.Multiaddr
110110
111111 // AddrStream returns a channel that gets all addresses for a given
112112 // peer sent on it. If new addresses are added after the call is made
113113 // they will be sent along through the channel as well.
114114 AddrStream (context.Context , peer.ID ) <- chan ma.Multiaddr
115115
116116 // ClearAddresses removes all previously stored addresses.
117- ClearAddrs (p peer.ID )
117+ ClearAddrs (context. Context , peer.ID )
118118
119119 // PeersWithAddrs returns all of the peer IDs stored in the AddrBook.
120- PeersWithAddrs () peer.IDSlice
120+ PeersWithAddrs (context. Context ) peer.IDSlice
121121}
122122
123123// CertifiedAddrBook manages "self-certified" addresses for remote peers.
@@ -172,12 +172,12 @@ type CertifiedAddrBook interface {
172172 // AddrBook.SetAddrs will be ignored. AddrBook.SetAddrs may still be used
173173 // to update the TTL of certified addresses that have previously been
174174 // added via ConsumePeerRecord.
175- ConsumePeerRecord (s * record.Envelope , ttl time.Duration ) (accepted bool , err error )
175+ ConsumePeerRecord (context. Context , * record.Envelope , time.Duration ) (accepted bool , err error )
176176
177177 // GetPeerRecord returns a Envelope containing a PeerRecord for the
178178 // given peer id, if one exists.
179179 // Returns nil if no signed PeerRecord exists for the peer.
180- GetPeerRecord (p peer.ID ) * record.Envelope
180+ GetPeerRecord (context. Context , peer.ID ) * record.Envelope
181181}
182182
183183// GetCertifiedAddrBook is a helper to "upcast" an AddrBook to a
@@ -196,24 +196,24 @@ func GetCertifiedAddrBook(ab AddrBook) (cab CertifiedAddrBook, ok bool) {
196196// KeyBook tracks the keys of Peers.
197197type KeyBook interface {
198198 // PubKey stores the public key of a peer.
199- PubKey (peer.ID ) ic.PubKey
199+ PubKey (context. Context , peer.ID ) ic.PubKey
200200
201201 // AddPubKey stores the public key of a peer.
202- AddPubKey (peer.ID , ic.PubKey ) error
202+ AddPubKey (context. Context , peer.ID , ic.PubKey ) error
203203
204204 // PrivKey returns the private key of a peer, if known. Generally this might only be our own
205205 // private key, see
206206 // https://discuss.libp2p.io/t/what-is-the-purpose-of-having-map-peer-id-privatekey-in-peerstore/74.
207- PrivKey (peer.ID ) ic.PrivKey
207+ PrivKey (context. Context , peer.ID ) ic.PrivKey
208208
209209 // AddPrivKey stores the private key of a peer.
210- AddPrivKey (peer.ID , ic.PrivKey ) error
210+ AddPrivKey (context. Context , peer.ID , ic.PrivKey ) error
211211
212212 // PeersWithKeys returns all the peer IDs stored in the KeyBook.
213- PeersWithKeys () peer.IDSlice
213+ PeersWithKeys (context. Context ) peer.IDSlice
214214
215215 // RemovePeer removes all keys associated with a peer.
216- RemovePeer (peer.ID )
216+ RemovePeer (context. Context , peer.ID )
217217}
218218
219219// Metrics tracks metrics across a set of peers.
@@ -226,25 +226,25 @@ type Metrics interface {
226226 LatencyEWMA (peer.ID ) time.Duration
227227
228228 // RemovePeer removes all metrics stored for a peer.
229- RemovePeer (peer.ID )
229+ RemovePeer (context. Context , peer.ID )
230230}
231231
232232// ProtoBook tracks the protocols supported by peers.
233233type ProtoBook interface {
234- GetProtocols (peer.ID ) ([]protocol.ID , error )
235- AddProtocols (peer.ID , ... protocol.ID ) error
236- SetProtocols (peer.ID , ... protocol.ID ) error
237- RemoveProtocols (peer.ID , ... protocol.ID ) error
234+ GetProtocols (context. Context , peer.ID ) ([]protocol.ID , error )
235+ AddProtocols (context. Context , peer.ID , ... protocol.ID ) error
236+ SetProtocols (context. Context , peer.ID , ... protocol.ID ) error
237+ RemoveProtocols (context. Context , peer.ID , ... protocol.ID ) error
238238
239239 // SupportsProtocols returns the set of protocols the peer supports from among the given protocols.
240240 // If the returned error is not nil, the result is indeterminate.
241- SupportsProtocols (peer.ID , ... protocol.ID ) ([]protocol.ID , error )
241+ SupportsProtocols (context. Context , peer.ID , ... protocol.ID ) ([]protocol.ID , error )
242242
243243 // FirstSupportedProtocol returns the first protocol that the peer supports among the given protocols.
244244 // If the peer does not support any of the given protocols, this function will return an empty protocol.ID and a nil error.
245245 // If the returned error is not nil, the result is indeterminate.
246- FirstSupportedProtocol (peer.ID , ... protocol.ID ) (protocol.ID , error )
246+ FirstSupportedProtocol (context. Context , peer.ID , ... protocol.ID ) (protocol.ID , error )
247247
248248 // RemovePeer removes all protocols associated with a peer.
249- RemovePeer (peer.ID )
249+ RemovePeer (context. Context , peer.ID )
250250}
0 commit comments