set destination address when for ledger window repair responses

This commit is contained in:
Rob Walker 2018-08-07 23:22:45 -07:00
parent a200cedb4b
commit c64e2acf8b
3 changed files with 12 additions and 2 deletions

View File

@ -1016,7 +1016,12 @@ impl Crdt {
if let Ok(entry) = ledger_window.get_entry(ix) { if let Ok(entry) = ledger_window.get_entry(ix) {
inc_new_counter!("crdt-window-request-ledger", 1); inc_new_counter!("crdt-window-request-ledger", 1);
let out = entry.to_blob(blob_recycler, Some(ix), Some(from.id)); let out = entry.to_blob(
blob_recycler,
Some(ix),
Some(from.id),
Some(&from.contact_info.tvu_window),
);
return Some(out); return Some(out);
} }

View File

@ -8,6 +8,7 @@ use packet::{BlobRecycler, SharedBlob, BLOB_DATA_SIZE};
use rayon::prelude::*; use rayon::prelude::*;
use signature::PublicKey; use signature::PublicKey;
use std::io::Cursor; use std::io::Cursor;
use std::net::SocketAddr;
use transaction::Transaction; use transaction::Transaction;
/// Each Entry contains three pieces of data. The `num_hashes` field is the number /// Each Entry contains three pieces of data. The `num_hashes` field is the number
@ -83,6 +84,7 @@ impl Entry {
blob_recycler: &BlobRecycler, blob_recycler: &BlobRecycler,
idx: Option<u64>, idx: Option<u64>,
id: Option<PublicKey>, id: Option<PublicKey>,
addr: Option<&SocketAddr>,
) -> SharedBlob { ) -> SharedBlob {
let blob = blob_recycler.allocate(); let blob = blob_recycler.allocate();
{ {
@ -100,6 +102,9 @@ impl Entry {
if let Some(id) = id { if let Some(id) = id {
blob_w.set_id(id).expect("set_id()"); blob_w.set_id(id).expect("set_id()");
} }
if let Some(addr) = addr {
blob_w.meta.set_addr(addr);
}
} }
blob blob
} }

View File

@ -399,7 +399,7 @@ impl Block for [Entry] {
fn to_blobs(&self, blob_recycler: &packet::BlobRecycler, q: &mut VecDeque<SharedBlob>) { fn to_blobs(&self, blob_recycler: &packet::BlobRecycler, q: &mut VecDeque<SharedBlob>) {
for entry in self { for entry in self {
let blob = entry.to_blob(blob_recycler, None, None); let blob = entry.to_blob(blob_recycler, None, None, None);
q.push_back(blob); q.push_back(blob);
} }
} }