Skip to content

Commit

Permalink
Fix nil pointer deref when using lite mode
Browse files Browse the repository at this point in the history
  • Loading branch information
chappjc committed Nov 7, 2017
1 parent 46c9c23 commit efaa57f
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,26 +176,28 @@ func mainCore() error {
}

var newPGIndexes, updateAllAddresses bool
heightDB, err := db.HeightDB()
if err != nil {
if err != sql.ErrNoRows {
return fmt.Errorf("Unable to get height from PostgreSQL DB: %v", err)
if usePG {
heightDB, err := db.HeightDB()
if err != nil {
if err != sql.ErrNoRows {
return fmt.Errorf("Unable to get height from PostgreSQL DB: %v", err)
}
heightDB = 0
}
heightDB = 0
}
blocksBehind := height - int64(heightDB)
if blocksBehind < 0 {
return fmt.Errorf("Node is still syncing. Node height = %d, "+
"DB height = %d", height, heightDB)
}
if blocksBehind > 7500 {
log.Infof("Setting PSQL sync to rebuild address table after large "+
"import (%d blocks).", blocksBehind)
updateAllAddresses = true
if blocksBehind > 40000 {
log.Infof("Setting PSQL sync to drop indexes prior to bulk data "+
blocksBehind := height - int64(heightDB)
if blocksBehind < 0 {
return fmt.Errorf("Node is still syncing. Node height = %d, "+
"DB height = %d", height, heightDB)
}
if blocksBehind > 7500 {
log.Infof("Setting PSQL sync to rebuild address table after large "+
"import (%d blocks).", blocksBehind)
newPGIndexes = true
updateAllAddresses = true
if blocksBehind > 40000 {
log.Infof("Setting PSQL sync to drop indexes prior to bulk data "+
"import (%d blocks).", blocksBehind)
newPGIndexes = true
}
}
}

Expand Down

0 comments on commit efaa57f

Please sign in to comment.