Skip to content

Commit

Permalink
chore(genesis): remove unnecessary error check in genesis files (#1416)
Browse files Browse the repository at this point in the history
Co-authored-by: Javad Rajabzadeh <[email protected]>
  • Loading branch information
b00f and Ja7ad authored Jul 13, 2024
1 parent 1f7d2c3 commit 37c1e76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
5 changes: 1 addition & 4 deletions genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ type genesisData struct {
}

func (gen *Genesis) Hash() hash.Hash {
bs, err := cbor.Marshal(gen.data)
if err != nil {
return hash.UndefHash
}
bs, _ := cbor.Marshal(gen.data)

return hash.CalcHash(bs)
}
Expand Down
8 changes: 3 additions & 5 deletions genesis/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import (
var mainnetJSON []byte

func MainnetGenesis() *Genesis {
var gen Genesis
if err := json.Unmarshal(mainnetJSON, &gen); err != nil {
panic(err)
}
gen := new(Genesis)
_ = json.Unmarshal(mainnetJSON, &gen)

return &gen
return gen
}
8 changes: 3 additions & 5 deletions genesis/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import (
var testnetJSON []byte

func TestnetGenesis() *Genesis {
var gen Genesis
if err := json.Unmarshal(testnetJSON, &gen); err != nil {
panic(err)
}
gen := new(Genesis)
_ = json.Unmarshal(testnetJSON, &gen)

return &gen
return gen
}

0 comments on commit 37c1e76

Please sign in to comment.