From 7bec3330178e6f09a2c3ff36ae107addcc79e875 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 27 Aug 2016 14:15:18 -0400 Subject: [PATCH] fix fast sync --- blockchain/reactor.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 53aa311cc..1cf78dcee 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -234,16 +234,18 @@ FOR_LOOP: err := bcR.state.ExecBlock(bcR.evsw, bcR.proxyAppConn, first, firstPartsHeader) if err != nil { // TODO This is bad, are we zombie? - PanicQ(Fmt("Failed to process committed block: %v", err)) + PanicQ(Fmt("Failed to process committed block (%d:%X): %v", first.Height, first.Hash(), err)) + } + // NOTE: we could improve performance if we + // didn't make the app commit to disk every block + // ... but we would need a way to get the hash without it persisting + res := bcR.proxyAppConn.CommitSync() + if res.IsErr() { + // TODO Handle gracefully. + PanicQ(Fmt("Failed to commit block at application: %v", res)) } - /* - err = bcR.proxyAppConn.CommitSync() - if err != nil { - // TODO Handle gracefully. - PanicQ(Fmt("Failed to commit block at application: %v", err)) - } - */ bcR.store.SaveBlock(first, firstParts, second.LastCommit) + bcR.state.AppHash = res.Data // ... bcR.state.Save() } }