Allow node to restart after halt config trigger (#5352)
* Allow node to restart after halt config trigger * Update godoc * Update documentation on halt config
This commit is contained in:
committed by
Federico Kunze
parent
7953b525d8
commit
b862e271a1
+18
-18
@@ -215,24 +215,6 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv
|
||||
func (app *BaseApp) Commit() (res abci.ResponseCommit) {
|
||||
header := app.deliverState.ctx.BlockHeader()
|
||||
|
||||
var halt bool
|
||||
|
||||
switch {
|
||||
case app.haltHeight > 0 && uint64(header.Height) >= app.haltHeight:
|
||||
halt = true
|
||||
|
||||
case app.haltTime > 0 && header.Time.Unix() >= int64(app.haltTime):
|
||||
halt = true
|
||||
}
|
||||
|
||||
if halt {
|
||||
app.halt()
|
||||
|
||||
// Note: State is not actually committed when halted. Logs from Tendermint
|
||||
// can be ignored.
|
||||
return abci.ResponseCommit{}
|
||||
}
|
||||
|
||||
// Write the DeliverTx state which is cache-wrapped and commit the MultiStore.
|
||||
// The write to the DeliverTx state writes all state transitions to the root
|
||||
// MultiStore (app.cms) so when Commit() is called is persists those values.
|
||||
@@ -249,6 +231,24 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
|
||||
// empty/reset the deliver state
|
||||
app.deliverState = nil
|
||||
|
||||
var halt bool
|
||||
|
||||
switch {
|
||||
case app.haltHeight > 0 && uint64(header.Height) >= app.haltHeight:
|
||||
halt = true
|
||||
|
||||
case app.haltTime > 0 && header.Time.Unix() >= int64(app.haltTime):
|
||||
halt = true
|
||||
}
|
||||
|
||||
if halt {
|
||||
// Halt the binary and allow Tendermint to receive the ResponseCommit
|
||||
// response with the commit ID hash. This will allow the node to successfully
|
||||
// restart and process blocks assuming the halt configuration has been
|
||||
// reset or moved to a more distant value.
|
||||
app.halt()
|
||||
}
|
||||
|
||||
return abci.ResponseCommit{
|
||||
Data: commitID.Hash,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user