mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: reduce default integrate cache size
This commit is contained in:
1 parent
fed6daae51
commit
a9a7b3a451
1 file changed
+3
-3
@@ -6,7 +6,7 @@ const _CACHE_INFO = {
|
|||||||
|
|
||||||
function _LOGP(x: number) {
|
function _LOGP(x: number) {
|
||||||
const sqrtPi = 2.506628274631; // Sqrt[Pi]
|
const sqrtPi = 2.506628274631; // Sqrt[Pi]
|
||||||
return (2 * Math.exp(-1.0 * (Math.log(x) ** 2) * 2)) / x / sqrtPi;
|
return (2 * Math.exp(-2.0 * (Math.log(x) ** 2))) / x / sqrtPi;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _intergrateEnsureCache(y: number) {
|
function _intergrateEnsureCache(y: number) {
|
||||||
@@ -27,7 +27,7 @@ function _intergrateEnsureCache(y: number) {
|
|||||||
return _CACHE_INFO;
|
return _CACHE_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
_intergrateEnsureCache(1000000);
|
_intergrateEnsureCache(10000);
|
||||||
|
|
||||||
function _integrate(y: number) {
|
function _integrate(y: number) {
|
||||||
_intergrateEnsureCache(y);
|
_intergrateEnsureCache(y);
|
||||||
@@ -38,7 +38,7 @@ function difficultyAlgorithm(nSubmit: number, nAccept: number) {
|
|||||||
if (!nSubmit) return null;
|
if (!nSubmit) return null;
|
||||||
const s = _integrate(nSubmit);
|
const s = _integrate(nSubmit);
|
||||||
const acRate = nAccept / nSubmit;
|
const acRate = nAccept / nSubmit;
|
||||||
const ans = Math.round(10.0 - 1.30 * s * 10.0 * acRate);
|
const ans = Math.round(10 - 13 * s * acRate);
|
||||||
return Math.max(ans, 1);
|
return Math.max(ans, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user