19 lines
580 B
Go
19 lines
580 B
Go
package peer
|
|
|
|
import "vppn/m"
|
|
|
|
// loadNetworkState reads a cached network state from disk. Any error (most
|
|
// commonly a missing file on first run) is returned to the caller, which
|
|
// treats it as "no cache available".
|
|
func loadNetworkState(path string) (m.NetworkState, error) {
|
|
var state m.NetworkState
|
|
err := loadJSON(path, &state)
|
|
return state, err
|
|
}
|
|
|
|
// saveNetworkState writes state to path atomically (see storeJSON), so a crash
|
|
// mid-write cannot leave a corrupt cache.
|
|
func saveNetworkState(path string, state m.NetworkState) error {
|
|
return storeJSON(path, state)
|
|
}
|