Fix panic in BanksServer (#12293)

Fixes #12167
This commit is contained in:
Greg Fitzgerald
2020-09-16 17:31:58 -06:00
committed by GitHub
parent 98cfe92745
commit 3ecb390b10

View File

@@ -23,7 +23,7 @@ use solana_sdk::{
use std::{
collections::HashMap,
io,
net::SocketAddr,
net::{Ipv4Addr, SocketAddr},
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver, Sender},
@@ -240,7 +240,12 @@ pub async fn start_tcp_server(
.filter_map(|r| future::ready(r.ok()))
.map(server::BaseChannel::with_defaults)
// Limit channels to 1 per IP.
.max_channels_per_key(1, |t| t.as_ref().peer_addr().unwrap().ip())
.max_channels_per_key(1, |t| {
t.as_ref()
.peer_addr()
.map(|x| x.ip())
.unwrap_or_else(|_| Ipv4Addr::new(0, 0, 0, 0).into())
})
// serve is generated by the service attribute. It takes as input any type implementing
// the generated Banks trait.
.map(move |chan| {