func NewState(file string, persistInterval uint64) (*State, error) {
	state := &State{
		Values:          make(map[string]string),
		file:            file,
		persistInterval: persistInterval,
	}
	state.Hash = hashItems(state.Values)
	err := state.load()
	switch {
	case errors.Is(err, os.ErrNotExist):
	case err != nil:
		return nil, err
	}
	return state, nil
}
NewState creates a new state.
package app
import (
	"crypto/sha256"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"sync"
)
type State struct {
	sync.RWMutex
	Height uint64
	Values map[string]string
	Hash   []byte
	file            string
	persistInterval uint64
	initialHeight   uint64
}