예제 #1
0
func SaveConfig(p *persist.Persist, c *ConsensusConfig) error {
	craw, err := proto.Marshal(c)
	if err != nil {
		return err
	}
	err = p.StoreState("config", craw)
	return err
}
예제 #2
0
func RestoreConfig(p *persist.Persist) (*ConsensusConfig, error) {
	raw, err := p.ReadState("config")
	if err != nil {
		return nil, err
	}
	config := &ConsensusConfig{}
	err = proto.Unmarshal(raw, config)
	if err != nil {
		return nil, err
	}
	return config, nil
}