func loadFridayFilePV(keyFilePath, stateFilePath string, loadState bool) *FridayFilePV {
	keyJSONBytes, err := ioutil.ReadFile(keyFilePath)
	if err != nil {
		cmn.Exit(err.Error())
	}
	pvKey := FilePVKey{}
	err = cdc.UnmarshalJSON(keyJSONBytes, &pvKey)
	if err != nil {
		cmn.Exit(fmt.Sprintf("Error reading PrivValidator key from %v: %v\n", keyFilePath, err))
	}

	// overwrite pubkey and address for convenience
	pvKey.PubKey = pvKey.PrivKey.PubKey()
	pvKey.Address = pvKey.PubKey.Address()
	pvKey.filePath = keyFilePath

	pvState := FridayFilePVSignState{}
	if loadState {
		stateJSONBytes, err := ioutil.ReadFile(stateFilePath)
		if err != nil {
			cmn.Exit(err.Error())
		}
		err = cdc.UnmarshalJSON(stateJSONBytes, &pvState)
		if err != nil {
			cmn.Exit(fmt.Sprintf("Error reading PrivValidator state from %v: %v\n", stateFilePath, err))
		}
	}

	pvState.filePath = stateFilePath

	return &FridayFilePV{
		Key:       pvKey,
		SignState: pvState,
	}
}
// If loadState is true, we load from the stateFilePath. Otherwise, we use an empty SignState.
If loadState is true, we load from the stateFilePath. Otherwise, we use an empty SignState.
// If loadState is true we load from the stateFilePath . Otherwise we use an empty SignState .
func loadFridayFilePV(keyFilePath, stateFilePath string, loadState bool) *FridayFilePV {
	keyJSONBytes, err := ioutil.ReadFile(keyFilePath)
	if err != nil {
		cmn.Exit(err.Error())
	}
	pvKey := FilePVKey{}
	err = cdc.UnmarshalJSON(keyJSONBytes, &pvKey)
	if err != nil {
		cmn.Exit(fmt.Sprintf("Error reading PrivValidator key from %v: %v\n", keyFilePath, err))
	}
	pvKey.PubKey = pvKey.PrivKey.PubKey()
	pvKey.Address = pvKey.PubKey.Address()
	pvKey.filePath = keyFilePath
	pvState := FridayFilePVSignState{}
	if loadState {
		stateJSONBytes, err := ioutil.ReadFile(stateFilePath)
		if err != nil {
			cmn.Exit(err.Error())
		}
		err = cdc.UnmarshalJSON(stateJSONBytes, &pvState)
		if err != nil {
			cmn.Exit(fmt.Sprintf("Error reading PrivValidator state from %v: %v\n", stateFilePath, err))
		}
	}
	pvState.filePath = stateFilePath
	return &FridayFilePV{
		Key:       pvKey,
		SignState: pvState,
	}
}
func loadFridayFilePV ( keyFilePath , stateFilePath string , loadState bool ) * FridayFilePV { keyJSONBytes , err := ioutil . ReadFile ( keyFilePath ) if err != nil { cmn . Exit ( err . Error ( ) ) } pvKey := FilePVKey { } err = cdc . UnmarshalJSON ( keyJSONBytes , & pvKey ) if err != nil { cmn . Exit ( fmt . Sprintf ( " \n " , keyFilePath , err ) ) } pvKey . PubKey = pvKey . PrivKey . PubKey ( ) pvKey . Address = pvKey . PubKey . Address ( ) pvKey . filePath = keyFilePath pvState := FridayFilePVSignState { } if loadState { stateJSONBytes , err := ioutil . ReadFile ( stateFilePath ) if err != nil { cmn . Exit ( err . Error ( ) ) } err = cdc . UnmarshalJSON ( stateJSONBytes , & pvState ) if err != nil { cmn . Exit ( fmt . Sprintf ( " \n " , stateFilePath , err ) ) } } pvState . filePath = stateFilePath return & FridayFilePV { Key : pvKey , SignState : pvState , } }
If loadState is true, we load from the stateFilePath.
If loadState is true we load from the stateFilePath .
// overwrite pubkey and address for convenience