Shuffle server at same heights
This commit is contained in:
parent
de506ba074
commit
c51cb51818
|
@ -647,12 +647,12 @@ pub unsafe extern "C" fn derive_zip32(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn get_downloaded_size() -> usize {
|
pub unsafe extern "C" fn get_downloaded_size() -> usize {
|
||||||
DOWNLOADED_BYTES.load(Ordering::SeqCst)
|
DOWNLOADED_BYTES.load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn get_trial_decryptions_count() -> usize {
|
pub unsafe extern "C" fn get_trial_decryptions_count() -> usize {
|
||||||
TRIAL_DECRYPTIONS.load(Ordering::SeqCst)
|
TRIAL_DECRYPTIONS.load(Ordering::Acquire)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
11
src/chain.rs
11
src/chain.rs
|
@ -7,6 +7,8 @@ use crate::{advance_tree, has_cuda};
|
||||||
use ff::PrimeField;
|
use ff::PrimeField;
|
||||||
use futures::{future, FutureExt};
|
use futures::{future, FutureExt};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
use rand::prelude::SliceRandom;
|
||||||
|
use rand::rngs::OsRng;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
@ -166,15 +168,15 @@ pub async fn download_chain(
|
||||||
hash: vec![],
|
hash: vec![],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
DOWNLOADED_BYTES.store(0, Ordering::SeqCst);
|
DOWNLOADED_BYTES.store(0, Ordering::Release);
|
||||||
TRIAL_DECRYPTIONS.store(0, Ordering::SeqCst);
|
TRIAL_DECRYPTIONS.store(0, Ordering::Release);
|
||||||
let mut block_stream = client
|
let mut block_stream = client
|
||||||
.get_block_range(Request::new(range))
|
.get_block_range(Request::new(range))
|
||||||
.await?
|
.await?
|
||||||
.into_inner();
|
.into_inner();
|
||||||
while let Some(mut block) = block_stream.message().await? {
|
while let Some(mut block) = block_stream.message().await? {
|
||||||
let block_size = get_block_size(&block);
|
let block_size = get_block_size(&block);
|
||||||
DOWNLOADED_BYTES.fetch_add(block_size, Ordering::SeqCst);
|
DOWNLOADED_BYTES.fetch_add(block_size, Ordering::Release);
|
||||||
if cancel.load(Ordering::Acquire) {
|
if cancel.load(Ordering::Acquire) {
|
||||||
log::info!("Canceling download");
|
log::info!("Canceling download");
|
||||||
break;
|
break;
|
||||||
|
@ -606,7 +608,8 @@ pub async fn get_best_server(servers: &[String]) -> Option<String> {
|
||||||
tokio::spawn(timeout(Duration::from_secs(1), get_height(s.to_string()))).boxed();
|
tokio::spawn(timeout(Duration::from_secs(1), get_height(s.to_string()))).boxed();
|
||||||
server_heights.push(server_height);
|
server_heights.push(server_height);
|
||||||
}
|
}
|
||||||
let server_heights = future::try_join_all(server_heights).await.ok()?;
|
let mut server_heights = future::try_join_all(server_heights).await.ok()?;
|
||||||
|
server_heights.shuffle(&mut OsRng);
|
||||||
|
|
||||||
server_heights
|
server_heights
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -125,7 +125,7 @@ fn collect_decrypted_notes(
|
||||||
for (output_index, co) in tx.outputs.iter().enumerate() {
|
for (output_index, co) in tx.outputs.iter().enumerate() {
|
||||||
let plaintext = &output_buffer[i * buffer_stride + 64..i * buffer_stride + 116];
|
let plaintext = &output_buffer[i * buffer_stride + 64..i * buffer_stride + 116];
|
||||||
// version and amount must be in range - 21 million ZEC is less than 0x0008 0000 0000 0000
|
// version and amount must be in range - 21 million ZEC is less than 0x0008 0000 0000 0000
|
||||||
if plaintext[0] <= 2 || plaintext[18] <= 0x07 || plaintext[19] != 0 {
|
if plaintext[0] <= 2 && plaintext[18] < 0x08 && plaintext[19] == 0 {
|
||||||
if let Some((note, pa)) =
|
if let Some((note, pa)) =
|
||||||
domain.parse_note_plaintext_without_memo_ivk(&ivk, plaintext)
|
domain.parse_note_plaintext_without_memo_ivk(&ivk, plaintext)
|
||||||
{
|
{
|
||||||
|
|
|
@ -140,7 +140,7 @@ pub async fn sync_async(
|
||||||
.iter()
|
.iter()
|
||||||
.map(|db| db.count_outputs as usize)
|
.map(|db| db.count_outputs as usize)
|
||||||
.sum::<usize>();
|
.sum::<usize>();
|
||||||
TRIAL_DECRYPTIONS.fetch_add(n_ivks * outputs, AtomicOrdering::SeqCst);
|
TRIAL_DECRYPTIONS.fetch_add(n_ivks * outputs, AtomicOrdering::Release);
|
||||||
for b in dec_blocks.iter() {
|
for b in dec_blocks.iter() {
|
||||||
let mut my_nfs: Vec<Nf> = vec![];
|
let mut my_nfs: Vec<Nf> = vec![];
|
||||||
for nf in b.spends.iter() {
|
for nf in b.spends.iter() {
|
||||||
|
|
Loading…
Reference in New Issue