-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plot filter value now is the function of height (#1979)
- Loading branch information
1 parent
04ef232
commit 1314dc7
Showing
2 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,33 @@ | ||
export const PLOT_FILTER = 512; | ||
const PLOT_FILTER_CONSTANTS = { | ||
mainnet: { | ||
HARD_FORK_HEIGHT: 5_496_000, | ||
PLOT_FILTER_128_HEIGHT: 10_542_000, | ||
PLOT_FILTER_64_HEIGHT: 15_592_000, | ||
PLOT_FILTER_32_HEIGHT: 20_643_000, | ||
}, | ||
testnet10: { | ||
HARD_FORK_HEIGHT: 2_997_292, | ||
PLOT_FILTER_128_HEIGHT: 3_061_804, | ||
PLOT_FILTER_64_HEIGHT: 8_010_796, | ||
PLOT_FILTER_32_HEIGHT: 13_056_556, | ||
}, | ||
}; | ||
|
||
export function getPlotFilter(height: number = 0, isTestnet: boolean = false) { | ||
const constants = isTestnet ? PLOT_FILTER_CONSTANTS.testnet10 : PLOT_FILTER_CONSTANTS.mainnet; | ||
let prefixBits = 9; | ||
|
||
if (height >= constants.PLOT_FILTER_32_HEIGHT) { | ||
prefixBits -= 4; | ||
} else if (height >= constants.PLOT_FILTER_64_HEIGHT) { | ||
prefixBits -= 3; | ||
} else if (height >= constants.PLOT_FILTER_128_HEIGHT) { | ||
prefixBits -= 2; | ||
} else if (height >= constants.HARD_FORK_HEIGHT) { | ||
prefixBits -= 1; | ||
} | ||
|
||
prefixBits = Math.max(0, prefixBits); | ||
|
||
return 2 ** prefixBits; | ||
} |