//TODO: write individual blocks. append as they come in
func (self *BlockchainFile) Save(filename string) error {
	var data []byte
	for _, b := range self.Blocks {
		data = append(data, Enc_block(b)...)
	}
	util.SaveBinary(filename, data, 0644)
	return nil
}
Beispiel #2
0
func (self *BlockSigs) Save(filename string) error {
	// Convert the Sigs map to an array of element
	sigs := make([]BlockSigSerialized, len(self.Sigs))
	i := 0
	for k, v := range self.Sigs {
		sigs[i] = BlockSigSerialized{
			BkSeq: k,
			Sig:   v,
		}
		i++
	}
	bss := BlockSigsSerialized{sigs}
	data := encoder.Serialize(bss)
	return util.SaveBinary(filename, data, 0644)
}
func (self *SerializedBlockchain) Save(filename string) error {
	data := encoder.Serialize(self)
	return util.SaveBinary(filename, data, 0644)
}