Skip to content

Commit

Permalink
#13 WIP on improvements to upgrade module
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Mar 25, 2019
1 parent 6ab0c39 commit 2d6d1a4
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 573 deletions.
9 changes: 6 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
"encoding/json"
"fmt"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/regen-network/regen-ledger/index/postgresql"
"github.com/regen-network/regen-ledger/x/consortium"
Expand All @@ -15,8 +16,8 @@ import (
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
"io/ioutil"
"os"
"path/filepath"

//"os"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -158,7 +159,7 @@ func NewXrnApp(logger log.Logger, db dbm.DB, postgresUrl string) *xrnApp {
app.espKeeper = esp.NewKeeper(app.espStoreKey, app.agentKeeper, app.geoKeeper, cdc)

app.upgradeKeeper = upgrade.NewKeeper(app.upgradeStoreKey, cdc)
app.upgradeKeeper.SetBeforeShutdowner(app.willUpgrade)
app.upgradeKeeper.SetDoShutdowner(app.shutdownOnUpgrade)
app.upgradeKeeper.SetUpgradeHandler("test3", func(ctx sdk.Context, plan upgrade.UpgradePlan) {
ctx.Logger().Info("In upgrade 3 handler!")
})
Expand Down Expand Up @@ -251,11 +252,13 @@ func (app *xrnApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci.
return abci.ResponseInitChain{}
}

func (app *xrnApp) willUpgrade(plan upgrade.UpgradePlan) {
func (app *xrnApp) shutdownOnUpgrade(ctx sdk.Context, plan upgrade.UpgradePlan) {
if len(plan.Memo) != 0 {
home := viper.GetString(cli.HomeFlag)
_ = ioutil.WriteFile(filepath.Join(home, "data", "upgrade-info"), []byte(plan.Memo), 0644)
}
ctx.Logger().Error(fmt.Sprintf("UPGRADE \"%s\" NEEDED needed at height %d: %s", plan.Name, ctx.BlockHeight(), plan.Memo))
os.Exit(1)
}

func (app *xrnApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
Expand Down
15 changes: 3 additions & 12 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
with import <nixpkgs>{};

buildGoPackage rec {
buildGoModule rec {
name = "regen-ledger";

goPackagePath = "github.com/regen-network/regen-ledger";
subPackages = [ "cmd/xrnd" "cmd/xrncli" ];

src = ./.;

# buildInputs = [ makeWrapper ];
# binPath = lib.makeBinPath [ ];

goDeps = ./deps.nix;

#postInstall = ''
# wrapProgram $bin/bin/dep2nix --prefix PATH ':' ${binPath}
#'';

meta = with stdenv.lib; {
description = "Regen Networks's Regen Ledger distributed ledger for planetary regeneration";
# TODO license = licenses.bsd3;
description = "Distributed ledger for planetary regeneration";
license = licenses.asl20;
homepage = https://github.com/regen-network/regen-ledger;
};
}
Loading

0 comments on commit 2d6d1a4

Please sign in to comment.