Skip to content

Commit

Permalink
chain id check
Browse files Browse the repository at this point in the history
  • Loading branch information
techcoderx committed May 20, 2021
1 parent b717dfe commit 156ca96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ var cache = {

var timeBefore = new Date().getTime()
parallel(executions, function(err, results) {
logr.debug(executions.length+' mongo queries executed in '+(new Date().getTime()-timeBefore)+'ms')
let execTime = new Date().getTime()-timeBefore
if (!rebuild && execTime >= config.blockTime/2)
logr.warn('Slow write execution: ' + executions.length + ' mongo queries took ' + execTime + 'ms')
else
logr.debug(executions.length+' mongo queries executed in '+execTime+'ms')
cache.changes = []
cache.inserts = []
cache.rebuild.changes = []
Expand Down
4 changes: 4 additions & 0 deletions src/p2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ var p2p = {
var challengeHash = p2p.sockets[p2p.sockets.indexOf(ws)].challengeHash
if (!challengeHash)
return
if (message.d.origin_block !== config.originHash) {
logr.debug('Different chain id, disconnecting')
return ws.close()
}
try {
var isValidSignature = secp256k1.ecdsaVerify(
bs58.decode(message.d.sign),
Expand Down

0 comments on commit 156ca96

Please sign in to comment.