mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
fix bug - p2p store was ignoring port numbers (#657)
This commit is contained in:
parent
d754b8d1e4
commit
5dce526f90
2 changed files with 4 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue