allows sendmmsg api taking owned values (as well as references) (#18999) (#20226)

Current signature of api in sendmmsg requires a slice of inner
references:
https://github.com/solana-labs/solana/blob/fe1ee4980/streamer/src/sendmmsg.rs#L130-L152

That forces the call-site to convert owned values to references even
though doing so is redundant and adds an extra level of indirection:
https://github.com/solana-labs/solana/blob/fe1ee4980/core/src/repair_service.rs#L291

This commit expands the api using AsRef and Borrow traits to allow
calling the method with owned values (as well as references like
before).

(cherry picked from commit 049fb0417f)

Co-authored-by: behzad nouri <behzadnouri@gmail.com>
This commit is contained in:
mergify[bot]
2021-09-26 20:35:13 +00:00
committed by GitHub
parent 88177d33fd
commit e9a993fb59
4 changed files with 41 additions and 17 deletions

View File

@@ -411,7 +411,7 @@ pub fn broadcast_shreds(
let seed = shred.seed(Some(self_pubkey), &root_bank);
let node = cluster_nodes.get_broadcast_peer(seed)?;
if socket_addr_space.check(&node.tvu) {
Some((&shred.payload[..], &node.tvu))
Some((&shred.payload, node.tvu))
} else {
None
}

View File

@@ -300,7 +300,6 @@ impl RepairService {
})
.collect()
};
let batch: Vec<(&[u8], &SocketAddr)> = batch.iter().map(|(v, s)| (&v[..], s)).collect();
build_repairs_batch_elapsed.stop();
let mut batch_send_repairs_elapsed = Measure::start("batch_send_repairs_elapsed");