fix bug - p2p store was ignoring port numbers (#657)

This commit is contained in:
Antioch Peverell 2018-01-29 09:45:01 -05:00 committed by GitHub
parent d754b8d1e4
commit 5dce526f90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -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 {

View file

@ -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())
}