GODT-2224: Allow the user to specify max sync memory usage in Vault

This commit is contained in:
Leander Beernaert
2023-01-31 09:13:41 +01:00
parent c8065c8092
commit c0aacb7d62
7 changed files with 67 additions and 9 deletions

View File

@ -178,7 +178,7 @@ func (vault *Vault) SetLastVersion(version *semver.Version) error {
})
}
// GetFirstStart sets whether this is the first time the bridge has been started.
// GetFirstStart returns whether this is the first time the bridge has been started.
func (vault *Vault) GetFirstStart() bool {
return vault.get().Settings.FirstStart
}
@ -189,3 +189,21 @@ func (vault *Vault) SetFirstStart(firstStart bool) error {
data.Settings.FirstStart = firstStart
})
}
// GetMaxSyncMemory returns the maximum amount of memory the sync process should use.
func (vault *Vault) GetMaxSyncMemory() uint64 {
v := vault.get().Settings.MaxSyncMemory
// can be zero if never written to vault before.
if v == 0 {
return DefaultMaxSyncMemory
}
return v
}
// SetMaxSyncMemory sets the maximum amount of memory the sync process should use.
func (vault *Vault) SetMaxSyncMemory(maxMemory uint64) error {
return vault.mod(func(data *Data) {
data.Settings.MaxSyncMemory = maxMemory
})
}