Skip to content

Commit

Permalink
Merge pull request #40 from eco-stake/handle-invalid-validators
Browse files Browse the repository at this point in the history
Handle invalid validators with no hexAddress
  • Loading branch information
tombeynon authored Oct 3, 2022
2 parents 8fb8106 + 251b9b1 commit 480dcaa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions validators/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ export class Validator {

missedBlocks(max){
const hexAddress = this.hexAddress()
const base64Address = toBase64(fromHex(hexAddress))
const base64Address = hexAddress && toBase64(fromHex(hexAddress))
const blocks = this.blocks.filter(block => {
return !block.signatures.find(el => [hexAddress, base64Address].includes(el))
return !hexAddress || !block.signatures.find(el => [hexAddress, base64Address].includes(el))
})
return blocks.slice(0, max || blocks.length)
}

signedBlocks(max){
const hexAddress = this.hexAddress()
const base64Address = toBase64(fromHex(hexAddress))
const base64Address = hexAddress && toBase64(fromHex(hexAddress))
const blocks = this.blocks.filter(block => {
return block.signatures.find(el => [hexAddress, base64Address].includes(el))
return hexAddress && block.signatures.find(el => [hexAddress, base64Address].includes(el))
})
return blocks.slice(0, max || blocks.length)
}
Expand Down

0 comments on commit 480dcaa

Please sign in to comment.