sophia ea87b6824d
Upgrade bolt to bbolt
boltdb/bolt is no longer a maintained project. bbolt is the CoreOS
fork that the author of boltdb suggests using as a replacement.
2022-04-25 12:24:34 -05:00

28 lines
558 B
Go

package state
import (
bolt "go.etcd.io/bbolt"
)
var (
serverIdKey = []byte("id")
)
// ServerIdSet writes the server ID.
func (s *State) ServerIdSet(id string) error {
return s.db.Update(func(dbTxn *bolt.Tx) error {
return dbTxn.Bucket(serverConfigBucket).Put(serverIdKey, []byte(id))
})
}
// ServerIdGet gets the server ID.
func (s *State) ServerIdGet() (string, error) {
var result string
err := s.db.View(func(dbTxn *bolt.Tx) error {
result = string(dbTxn.Bucket(serverConfigBucket).Get(serverIdKey))
return nil
})
return result, err
}