fix bug - p2p store was ignoring port numbers (#657)
This commit is contained in:
@@ -314,6 +314,7 @@ impl Readable for GetPeerAddrs {
|
||||
|
||||
/// Peer addresses we know of that are fresh enough, in response to
|
||||
/// GetPeerAddrs.
|
||||
#[derive(Debug)]
|
||||
pub struct PeerAddrs {
|
||||
pub peers: Vec<SockAddr>,
|
||||
}
|
||||
@@ -375,6 +376,7 @@ impl Readable for PeerError {
|
||||
/// Only necessary so we can implement Readable and Writeable. Rust disallows
|
||||
/// implementing traits when both types are outside of this crate (which is the
|
||||
/// case for SocketAddr and Readable/Writeable).
|
||||
#[derive(Debug)]
|
||||
pub struct SockAddr(pub SocketAddr);
|
||||
|
||||
impl Writeable for SockAddr {
|
||||
|
||||
+2
-2
@@ -130,7 +130,7 @@ impl PeerStore {
|
||||
}
|
||||
|
||||
/// List all known peers
|
||||
/// Used for /v1/peers, for seed / sync (debug & if too few peers connected)
|
||||
/// Used for /v1/peers/all api endpoint
|
||||
pub fn all_peers(&self) -> Vec<PeerData> {
|
||||
self.db
|
||||
.iter::<PeerData>(&to_key(PEER_PREFIX, &mut "".to_string().into_bytes()))
|
||||
@@ -155,5 +155,5 @@ impl PeerStore {
|
||||
}
|
||||
|
||||
fn peer_key(peer_addr: SocketAddr) -> Vec<u8> {
|
||||
to_key(PEER_PREFIX, &mut format!("{}", peer_addr.ip()).into_bytes())
|
||||
to_key(PEER_PREFIX, &mut format!("{}:{}", peer_addr.ip(), peer_addr.port()).into_bytes())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user