mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 04:30:04 +00:00
10b237e72d
* db methods: remove Get prefix for getter functions * db methods: consistent test names by removing Get
35 lines
701 B
Go
35 lines
701 B
Go
package db
|
|
|
|
import (
|
|
"github.com/boltdb/bolt"
|
|
)
|
|
|
|
// SimulatorSlot returns the last saved simulator slot
|
|
// from the disk.
|
|
func (db *BeaconDB) SimulatorSlot() (uint64, error) {
|
|
var slot uint64
|
|
err := db.view(func(tx *bolt.Tx) error {
|
|
b := tx.Bucket(simulatorBucket)
|
|
|
|
enc := b.Get(simSlotLookupKey)
|
|
if enc == nil {
|
|
return nil
|
|
}
|
|
|
|
slot = decodeToSlotNumber(enc)
|
|
return nil
|
|
})
|
|
|
|
return slot, err
|
|
}
|
|
|
|
// SaveSimulatorSlot saves the current slot of the simulator to the disk.
|
|
func (db *BeaconDB) SaveSimulatorSlot(slot uint64) error {
|
|
return db.update(func(tx *bolt.Tx) error {
|
|
b := tx.Bucket(simulatorBucket)
|
|
enc := encodeSlotNumber(slot)
|
|
|
|
return b.Put(simSlotLookupKey, enc)
|
|
})
|
|
}
|