Исправить повтор смены ключей после публикации candidate-цепочки

This commit is contained in:
AidarKC
2026-09-27 16:35:27 +03:00
parent 151a2c1754
commit f5698771e4
2 changed files with 14 additions and 2 deletions
+8 -2
View File
@@ -79,6 +79,11 @@ export class KeyRotationClient {
const cutoff=Number(rotation.forkFromBlock); const source=String(rotation.sourceBlockchainName||'');
if(!source || !Number.isInteger(cutoff) || cutoff<0) throw new Error('Некорректное состояние ротации');
if(String(newBundle?.blockchainPair?.publicKeyB64||'') !== String(rotation.newBlockchainKey||'')) throw new Error('Новый пароль выводит другой blockchain key');
const total=cutoff+2;
if(Number(rotation.progressCurrent)||0 >= total) {
onProgress({ phase:'copy', current:total, total });
return;
}
const owner32=base64ToBytes(newBundle.blockchainPair.publicKeyB64);
const privateKey=newBundle.blockchainPair.privateKey;
let start=Math.max(0, Math.min(cutoff+1, Number(rotation.progressCurrent)||0));
@@ -106,10 +111,11 @@ export class KeyRotationClient {
reasonCode:rotation.reasonCode,
comment:rotation.comment,
});
const techFrame=makeFrame({ prevHash:rotation.forkFromHash, blockNumber:cutoff+1, type:0, subType:TECH_FORK_SUBTYPE, version:1, body:forkBody });
const techTimestampMs=Number(rotation.createdAtMs)||Number(parentTipTimestampMs)+1000;
const techFrame=makeFrame({ prevHash:rotation.forkFromHash, blockNumber:cutoff+1, type:0, subType:TECH_FORK_SUBTYPE, version:1, body:forkBody, timestampMs:techTimestampMs });
const techRaw=await createAns104DataItem({ owner32, privateKey, data:techFrame, tags:[{name:'App',value:'test5590'}] });
await this.addCandidate({ blockNumber:cutoff+1, prevBlockHash:rotation.forkFromHash, blockBytesB64:bytesToBase64(techRaw) });
onProgress({ phase:'copy', current:cutoff+2, total:cutoff+2 });
onProgress({ phase:'copy', current:total, total });
}
async #sourcePrevHash(source, blockNumber) {