Commit 046d8c27 authored by 0x1337's avatar 0x1337

ir +1

parent 94455257
......@@ -1184,8 +1184,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, []
case err != nil:
stats.ignored += len(it.chain)
bc.reportBlock(block, nil, err)
SyncStatus = false
return it.index, events, coalescedLogs, err
return it.index + 1, events, coalescedLogs, err
}
// No validation errors for the first block (or chain prefix skipped)
for ; block != nil && err == nil; block, err = it.next() {
......
......@@ -9,7 +9,7 @@ import (
"git.pirl.io/community/pirl/params"
)
var SyncStatus bool
var syncStatus bool
func (bc *BlockChain) checkChainForAttack(blocks types.Blocks) error {
// Copyright 2014 The go-ethereum Authors
......@@ -35,18 +35,18 @@ func (bc *BlockChain) checkChainForAttack(blocks types.Blocks) error {
timeMap := make(map[uint64]int64)
tipOfTheMainChain := bc.CurrentBlock().NumberU64()
if !SyncStatus {
if !syncStatus {
if tipOfTheMainChain == blocks[0].NumberU64()-1 {
//fmt.Println("We are synced")
SyncStatus = true
syncStatus = true
} else {
//fmt.Println("Still syncing!")
SyncStatus = false
syncStatus = false
}
}
if len(blocks) > 0 && bc.CurrentBlock().NumberU64() > uint64(params.TimeCapsuleBlock) {
if SyncStatus && len(blocks) > int(params.TimeCapsuleLength) {
if syncStatus && len(blocks) > int(params.TimeCapsuleLength) {
for _, b := range blocks {
timeMap[b.NumberU64()] = calculatePenaltyTimeForBlock(tipOfTheMainChain, b.NumberU64())
}
......@@ -72,7 +72,7 @@ func (bc *BlockChain) checkChainForAttack(blocks types.Blocks) error {
}
//fmt.Println("Penalty value for the chain :", penalty)
context := []interface{}{
"synced", SyncStatus, "number", tipOfTheMainChain, "incoming_number", blocks[0].NumberU64() - 1, "penalty", penalty, "implementation", "The Pirl Team",
"synced", syncStatus, "number", tipOfTheMainChain, "incoming_number", blocks[0].NumberU64() - 1, "penalty", penalty, "implementation", "The Pirl Team",
}
log.Info("checking legitimity of the chain", context...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment