Skip to content

Commit

Permalink
Problem: windows build fails
Browse files Browse the repository at this point in the history
Solution: Revert "Problem: genesis file is updated non-atomically (fixes #398) (#399)"

This reverts commit 31b42bc.
  • Loading branch information
tomtau committed Mar 9, 2021
1 parent 2d553f8 commit d6a40e8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
## v1.0.1
A version based on the upstream release of Cosmos SDK 0.42.0.
(Note that the SDK 0.42.0 release is nearly identical to the patched SDK fork 0.41.4 that was used in 1.0.0.)
### Improvements
* [399](https://github.com/crypto-com/chain-main/pull/399) atomic updates to genesis file

*March 4, 2021*
## v1.0.0
Expand Down
19 changes: 9 additions & 10 deletions cmd/chain-maind/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/crypto-org-chain/chain-main/v1/app/params"
"github.com/crypto-org-chain/chain-main/v1/config"
chainmaincli "github.com/crypto-org-chain/chain-main/v1/x/chainmain/client/cli"
"github.com/google/renameio"
)

// NewRootCmd creates a new root command for chain-maind. It is called once in the
Expand Down Expand Up @@ -144,20 +143,20 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
}
}()
var genesis map[string]interface{}
if decodeErr := json.NewDecoder(file).Decode(&genesis); decodeErr != nil {
return decodeErr
if err := json.NewDecoder(file).Decode(&genesis); err != nil {
return err
}

if mergeErr := mergo.Merge(&genesis, genesisPatch, mergo.WithOverride); mergeErr != nil {
return mergeErr
if err := mergo.Merge(&genesis, genesisPatch, mergo.WithOverride); err != nil {
return err
}

bz, err := json.MarshalIndent(genesis, "", " ")
if err != nil {
if err := file.Truncate(0); err != nil {
return err
}

return renameio.WriteFile(cleanedPath, bz, 0600)
if _, err := file.Seek(0, 0); err != nil {
return err
}
return json.NewEncoder(file).Encode(&genesis)
}

rootCmd.AddCommand(
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let
src = lib.sourceByRegex ./. src_regexes;
};
subPackages = [ "cmd/chain-maind" ];
vendorSha256 = sha256:0rrl0slpz5z98ii6yl170jaz3n1i2ijbgc5z7wkpk3yyb3fpzb2h;
vendorSha256 = sha256:04xdhz9gldml9sm359algdb8aykyspsayngzmgr4mm85v57yzgwd;
runVend = true;
outputs = [
"out"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/gogo/protobuf v1.3.3
github.com/golang/protobuf v1.4.3
github.com/google/renameio v1.0.0
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/imdario/mergo v0.3.11
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/renameio v1.0.0 h1:xhp2CnJmgQmpJU4RY8chagahUq5mbPPAbiSQstKpVMA=
github.com/google/renameio v1.0.0/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
Expand Down

0 comments on commit d6a40e8

Please sign in to comment.