Skip to content
Snippets Groups Projects
Unverified Commit 3be08088 authored by Éloïs's avatar Éloïs
Browse files

[fix] step reception

parent 294b85b8
No related branches found
No related tags found
3 merge requests!1222Add startup scripts,!1220Stable/ws2p v1.1 trymerge,!1208Stable/ws2p v1.1
...@@ -142,7 +142,7 @@ export class WS2PCluster { ...@@ -142,7 +142,7 @@ export class WS2PCluster {
} }
const [,,, pub, blockstamp, ws2pId,,,,,]:string[] = messageV2.split(':') const [,,, pub, blockstamp, ws2pId,,,,,]:string[] = messageV2.split(':')
const fullId = [pub, ws2pId].join('-') const fullId = [pub, ws2pId].join('-')
this.headReceived(messageV2, sigV2, pub, fullId, blockstamp) this.headReceived(messageV2, sigV2, pub, fullId, blockstamp, step)
} }
if (!message) { if (!message) {
throw "EMPTY_MESSAGE_FOR_HEAD" throw "EMPTY_MESSAGE_FOR_HEAD"
...@@ -170,7 +170,7 @@ export class WS2PCluster { ...@@ -170,7 +170,7 @@ export class WS2PCluster {
this.newHeads = [] this.newHeads = []
} }
private async headReceived(message:string, sig:string, pub:string, fullId:string, blockstamp:string) { private async headReceived(message:string, sig:string, pub:string, fullId:string, blockstamp:string, step?:number) {
try { try {
const sigOK = verify(message, sig, pub) const sigOK = verify(message, sig, pub)
if (sigOK) { if (sigOK) {
...@@ -183,8 +183,8 @@ export class WS2PCluster { ...@@ -183,8 +183,8 @@ export class WS2PCluster {
if (isAllowed) { if (isAllowed) {
const exists = await this.existsBlock(blockstamp) const exists = await this.existsBlock(blockstamp)
if (exists) { if (exists) {
this.headsCache[fullId] = { blockstamp, message, sig } this.headsCache[fullId] = { blockstamp, message, sig, step }
this.newHeads.push({message, sig}) this.newHeads.push({message, sig, step})
// Cancel a pending "heads" to be spread // Cancel a pending "heads" to be spread
if (this.headsTimeout) { if (this.headsTimeout) {
clearTimeout(this.headsTimeout) clearTimeout(this.headsTimeout)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment