예제 #1
0
func (fs *FragmentStorage) SetHardState(st pb.HardState) error {
	fs.fhardState.Seek(0, 0)
	if data, e := st.Marshal(); e != nil {
		return e
	} else {
		_, e = fmt.Fprintln(fs.fhardState, data)
		return e
	}
	return nil
}
예제 #2
0
func (fs *FragmentStorage) getHardState() (pb.HardState, error) {
	r := bufio.NewReader(fs.fhardState)
	hs := pb.HardState{}
	if data, e := r.ReadSlice('\n'); e != nil {
		return hs, e
	} else {
		data = data[:len(data)-1]
		return hs, hs.Unmarshal(data)
	}
	return hs, nil
}