diff --git a/app/base.go b/app/base.go index 4b15fa070c..216a472c36 100644 --- a/app/base.go +++ b/app/base.go @@ -224,22 +224,11 @@ func (app *BaseApp) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQue // Commit implements abci.Application func (app *BaseApp) Commit() (res abci.Result) { - /* - hash, err := app.state.Commit(app.height) - if err != nil { - // die if we can't commit, not to recover - panic(err) - } - app.logger.Debug("Commit synced", - "height", app.height, - "hash", fmt.Sprintf("%X", hash), - ) - - if app.state.Size() == 0 { - return abci.NewResultOK(nil, "Empty hash for empty tree") - } - return abci.NewResultOK(hash, "") - */ + commitID := app.store.Commit() + app.logger.Debug("Commit synced", + "commit", commitID, + ) + return abci.NewResultOK(hash, "") } // InitChain - ABCI @@ -253,7 +242,7 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) { // EndBlock - ABCI // Returns a list of all validator changes made in this block func (app *BaseApp) EndBlock(height uint64) (res abci.ResponseEndBlock) { - // TODO: Compress duplicates + // XXX Update to res.Updates. res.Diffs = app.valSetDiff app.valSetDiff = nil return diff --git a/app/doc.go b/app/doc.go index c81e394320..c207ff31d6 100644 --- a/app/doc.go +++ b/app/doc.go @@ -1,9 +1,11 @@ /* Package app contains data structures that provide basic data storage -functionality and act as a bridge between the ABCI interface and the internal -SDK representations. +functionality and act as a bridge between the ABCI interface and the SDK +abstractions. -BaseApp has no state except the MultiStore you provide upon init. You must -also provide a Handler and a TxParser. +BaseApp has no state except the CommitMultiStore you provide upon init. You must +also provide a Handler. + +Transaction parsing is typically handled by the first Decorator. */ package app diff --git a/app/init.go b/app/init.go deleted file mode 100644 index f7b71d2f56..0000000000 --- a/app/init.go +++ /dev/null @@ -1,65 +0,0 @@ -package app - -import ( - "fmt" - - abci "github.com/tendermint/abci/types" - - sdk "github.com/cosmos/cosmos-sdk" -) - -// InitApp - The ABCI application with initialization hooks -type InitApp struct { - *BaseApp - initState sdk.InitStater - initVals sdk.InitValidator -} - -var _ abci.Application = &InitApp{} - -// NewInitApp extends a BaseApp with initialization callbacks, -// which it binds to the proper abci calls -func NewInitApp(base *BaseApp, initState sdk.InitStater, - initVals sdk.InitValidator) *InitApp { - - return &InitApp{ - BaseApp: base, - initState: initState, - initVals: initVals, - } -} - -// InitState - used to setup state (was SetOption) -// to be call from setting up the genesis file -func (app *InitApp) InitState(module, key, value string) error { - state := app.Append() - logger := app.Logger().With("module", module, "key", key) - - if module == sdk.ModuleNameBase { - if key == sdk.ChainKey { - app.info.SetChainID(state, value) - return nil - } - logger.Error("Invalid genesis option") - return fmt.Errorf("Unknown base option: %s", key) - } - - log, err := app.initState.InitState(logger, state, module, key, value) - if err != nil { - logger.Error("Invalid genesis option", "err", err) - } else { - logger.Info(log) - } - return err -} - -// InitChain - ABCI - sets the initial validators -func (app *InitApp) InitChain(req abci.RequestInitChain) { - // return early if no InitValidator registered - if app.initVals == nil { - return - } - - logger, store := app.Logger(), app.Append() - app.initVals.InitValidators(logger, store, req.Validators) -} diff --git a/store/types.go b/store/types.go index 51582f8bb9..556320f556 100644 --- a/store/types.go +++ b/store/types.go @@ -153,6 +153,10 @@ func (cid CommitID) IsZero() bool { return cid.Version == 0 && len(cid.Hash) == 0 } +func (cid CommitID) String() string { + return fmt.Spritnf("CommitID{%v:%X}", cid.Hash, cid.Version) +} + // bytes.Compare but bounded on both sides by nil. // both (k1, nil) and (nil, k2) return -1 func keyCompare(k1, k2 []byte) int {