// Upgrade convets the OldFilePV to the new FilePV, separating the immutable and mutable components,
// and persisting them to the keyFilePath and stateFilePath, respectively.
// It renames the original file by adding ".bak".
Upgrade convets the OldFilePV to the new FilePV, separating the immutable and mutable components,
and persisting them to the keyFilePath and stateFilePath, respectively.
It renames the original file by adding ".bak".
// Upgrade convets the OldFilePV to the new FilePV separating the immutable and mutable components // and persisting them to the keyFilePath and stateFilePath respectively . // It renames the original file by adding " . bak " .
func (oldFilePV *OldFilePV) Upgrade(keyFilePath, stateFilePath string) *FilePV {
	privKey := oldFilePV.PrivKey
	pvKey := FilePVKey{
		PrivKey:  privKey,
		PubKey:   privKey.PubKey(),
		Address:  privKey.PubKey().Address(),
		filePath: keyFilePath,
	}
	pvState := FilePVLastSignState{
		Height:    oldFilePV.LastHeight,
		Round:     oldFilePV.LastRound,
		Step:      oldFilePV.LastStep,
		Signature: oldFilePV.LastSignature,
		SignBytes: oldFilePV.LastSignBytes,
		filePath:  stateFilePath,
	}
	pv := &FilePV{
		Key:           pvKey,
		LastSignState: pvState,
	}
	pv.Save()
	err := os.Rename(oldFilePV.filePath, oldFilePV.filePath+".bak")
	if err != nil {
		panic(err)
	}
	return pv
}
func ( oldFilePV * OldFilePV ) Upgrade ( keyFilePath , stateFilePath string ) * FilePV { privKey := oldFilePV . PrivKey pvKey := FilePVKey { PrivKey : privKey , PubKey : privKey . PubKey ( ) , Address : privKey . PubKey ( ) . Address ( ) , filePath : keyFilePath , } pvState := FilePVLastSignState { Height : oldFilePV . LastHeight , Round : oldFilePV . LastRound , Step : oldFilePV . LastStep , Signature : oldFilePV . LastSignature , SignBytes : oldFilePV . LastSignBytes , filePath : stateFilePath , } pv := & FilePV { Key : pvKey , LastSignState : pvState , } pv . Save ( ) err := os . Rename ( oldFilePV . filePath , oldFilePV . filePath + " " ) if err != nil { panic ( err ) } return pv }
Upgrade convets the OldFilePV to the new FilePV, separating the immutable and mutable components,
and persisting them to the keyFilePath and stateFilePath, respectively.
Upgrade convets the OldFilePV to the new FilePV separating the immutable and mutable components and persisting them to the keyFilePath and stateFilePath respectively .
// Save the new PV files // Rename the old PV file