Fix BlockchainReactor bug w/ mismatched state.LastBlockHeight vs store.Height

This is due to a non-atomic saves of state.State vs blockchain.Store.
This is a simple hack.
This commit is contained in:
Jae Kwon 2015-12-07 16:57:33 -08:00
parent 12c7f00c44
commit 3da76496b0
1 changed files with 20 additions and 18 deletions

View File

@ -56,8 +56,10 @@ type BlockchainReactor struct {
}
func NewBlockchainReactor(state *sm.State, proxyAppCtx proxy.AppContext, store *BlockStore, sync bool) *BlockchainReactor {
if state.LastBlockHeight != store.Height() &&
state.LastBlockHeight != store.Height()-1 { // XXX double check this logic.
if state.LastBlockHeight == store.Height()-1 {
store.height -= 1 // XXX HACK, make this better
}
if state.LastBlockHeight != store.Height() {
PanicSanity(Fmt("state (%v) and store (%v) height mismatch", state.LastBlockHeight, store.Height()))
}
requestsCh := make(chan BlockRequest, defaultChannelCapacity)