only run client evalPut when local depth > cloud depth

deepcrayonfish^2
Thibault Duplessis 2021-11-28 18:40:28 +01:00
parent ece947fd20
commit 80523a2224
1 changed files with 3 additions and 2 deletions

View File

@ -75,10 +75,11 @@ export function make(opts: EvalCacheOpts): EvalCache {
const upgradable = prop(false);
lichess.pubsub.on('socket.in.crowd', d => upgradable(d.nb > 2 && d.nb < 99999));
return {
onCeval: throttle(500, function () {
onCeval: throttle(500, () => {
const node = opts.getNode(),
ev = node.ceval;
if (ev && !ev.cloud && node.fen in fetchedByFen && qualityCheck(ev) && opts.canPut()) {
const fetched = fetchedByFen[node.fen];
if (ev && !ev.cloud && fetched && ev.depth > fetched.depth && qualityCheck(ev) && opts.canPut()) {
opts.send('evalPut', toPutData(opts.variant, ev));
}
}),