Skip to content

Commit

Permalink
Merge remote-tracking branch 'msutton-origin/tn11-param-tuning' into …
Browse files Browse the repository at this point in the history
…tn11-compiled
  • Loading branch information
coderofstuff committed Dec 13, 2023
2 parents 5f12b4b + 7d8c1f7 commit 9326962
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions protocol/flows/src/flow_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const PROTOCOL_VERSION: u32 = 6;
/// See `check_orphan_resolution_range`
const BASELINE_ORPHAN_RESOLUTION_RANGE: u32 = 5;

/// Orphans are kept as full blocks so we cannot hold too much of them in memory
const MAX_ORPHANS_UPPER_BOUND: usize = 1024;

/// The min time to wait before allowing another parallel request
const REQUEST_SCOPE_WAIT_TIME: Duration = Duration::from_secs(1);

Expand Down Expand Up @@ -205,9 +208,9 @@ impl FlowContext {

let orphan_resolution_range = BASELINE_ORPHAN_RESOLUTION_RANGE + (config.bps() as f64).log2().ceil() as u32;

// The maximum amount of orphans allowed in the orphans pool. This number is an
// approximation of how many orphans there can possibly be on average.
let max_orphans = 2u64.pow(orphan_resolution_range) as usize * config.ghostdag_k as usize;
// The maximum amount of orphans allowed in the orphans pool. This number is an approximation
// of how many orphans there can possibly be on average bounded by an upper bound.
let max_orphans = (2u64.pow(orphan_resolution_range) as usize * config.ghostdag_k as usize).min(MAX_ORPHANS_UPPER_BOUND);
Self {
inner: Arc::new(FlowContextInner {
node_id: Uuid::new_v4().into(),
Expand Down

0 comments on commit 9326962

Please sign in to comment.