Skip to content
Snippets Groups Projects
Unverified Commit 578e4344 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

genesis: remove redundant copy of public key bytes on clone - thx to Silas

parent 441c1a6d
No related branches found
No related tags found
No related merge requests found
...@@ -130,19 +130,13 @@ func (genesisValidator *GenesisValidator) Clone() (GenesisValidator, error) { ...@@ -130,19 +130,13 @@ func (genesisValidator *GenesisValidator) Clone() (GenesisValidator, error) {
return GenesisValidator{}, fmt.Errorf("Invalid GenesisValidator %s with nil public key.", return GenesisValidator{}, fmt.Errorf("Invalid GenesisValidator %s with nil public key.",
genesisValidator.Name) genesisValidator.Name)
} }
// clone the public key by writing and reading over go-wire serialisation
// TODO! write unit test to see whether this is correct
publicKeyClone, err := crypto.PubKeyFromBytes(genesisValidator.PubKey.Bytes())
if err != nil {
return GenesisValidator{}, err
}
// clone the addresses to unbond to // clone the addresses to unbond to
unbondToClone := make([]BasicAccount, len(genesisValidator.UnbondTo)) unbondToClone := make([]BasicAccount, len(genesisValidator.UnbondTo))
for i, basicAccount := range genesisValidator.UnbondTo { for i, basicAccount := range genesisValidator.UnbondTo {
unbondToClone[i] = basicAccount.Clone() unbondToClone[i] = basicAccount.Clone()
} }
return GenesisValidator{ return GenesisValidator{
PubKey: publicKeyClone, PubKey: genesisValidator.PubKey,
Amount: genesisValidator.Amount, Amount: genesisValidator.Amount,
Name: genesisValidator.Name, Name: genesisValidator.Name,
UnbondTo: unbondToClone, UnbondTo: unbondToClone,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment