Esempio n. 1
0
// encryptAndSaveSeedFile encrypts and saves a seed file.
func (w *Wallet) encryptAndSaveSeedFile(masterKey crypto.TwofishKey, seed modules.Seed) (SeedFile, error) {
	var sf SeedFile
	_, err := rand.Read(sf.UID[:])
	if err != nil {
		return SeedFile{}, err
	}
	sek := uidEncryptionKey(masterKey, sf.UID)
	plaintextVerification := make([]byte, encryptionVerificationLen)
	sf.EncryptionVerification, err = sek.EncryptBytes(plaintextVerification)
	if err != nil {
		return SeedFile{}, err
	}
	sf.Seed, err = sek.EncryptBytes(seed[:])
	if err != nil {
		return SeedFile{}, err
	}
	seedFilename := filepath.Join(w.persistDir, seedFilePrefix+persist.RandomSuffix()+seedFileSuffix)
	err = persist.SaveFileSync(seedMetadata, sf, seedFilename)
	if err != nil {
		return SeedFile{}, err
	}
	return sf, nil
}
Esempio n. 2
0
func (p *stdPersist) saveSync(data contractorPersist) error {
	return persist.SaveFileSync(p.meta, data, p.filename)
}
Esempio n. 3
0
// saveSync stores the current renter data to disk and then syncs to disk.
func (r *Renter) saveSync() error {
	data := struct {
		Tracking map[string]trackedFile
	}{r.tracking}
	return persist.SaveFileSync(saveMetadata, data, filepath.Join(r.persistDir, PersistFilename))
}
Esempio n. 4
0
// saveSync stores the Gateway's persistent data on disk, and then syncs to
// disk to minimize the possibility of data loss.
func (g *Gateway) saveSync() error {
	return persist.SaveFileSync(persistMetadata, g.persistData(), filepath.Join(g.persistDir, nodesFile))
}
Esempio n. 5
0
// saveSettingsSync writes the wallet's settings to the wallet's settings file,
// replacing the existing file, and then syncs to disk.
func (w *Wallet) saveSettingsSync() error {
	return persist.SaveFileSync(settingsMetadata, w.persist, filepath.Join(w.persistDir, settingsFile))
}
Esempio n. 6
0
// createBackup creates a backup file at the desired filepath.
func (w *Wallet) createBackup(backupFilepath string) error {
	return persist.SaveFileSync(settingsMetadata, w.persist, backupFilepath)
}
Esempio n. 7
0
// saveSync saves the miner persistence to disk, and then syncs to disk.
func (m *Miner) saveSync() error {
	return persist.SaveFileSync(settingsMetadata, m.persist, filepath.Join(m.persistDir, settingsFile))
}
Esempio n. 8
0
// saveSync stores all of the persist data to disk and then syncs to disk.
func (h *Host) saveSync() error {
	return persist.SaveFileSync(persistMetadata, h.persistData(), filepath.Join(h.persistDir, settingsFile))
}
Esempio n. 9
0
// save stores all of the persistent data of the storage manager to disk.
func (sm *StorageManager) saveSync() error {
	return persist.SaveFileSync(persistMetadata, sm.persistData(), filepath.Join(sm.persistDir, settingsFile))
}