prysm-pulse/beacon-chain/db/simulator.go
Nishant Das 16b04699d0 Allow Initial Sync to Work with Simulator (#669)
* polling interval

* adding proto message

* changing proto messages

* changing naming

* adding slot functionality

* initial sync working

* new changes

* more sync fixes

* its working now

* finally working

* add tests

* fix tests

* tests

* adding tests

* lint

* log checks

* making changes to simulator

* update logs

* fix tests

* get sync to work with crystallized state

* fixing race

* making requested changes

* unexport

* documentation

* gazelle and fix merge conflicts

* adding repeated requests

* fix lint

* adding new clock , db methods, and util func

* revert change to test

* gazelle

* add in test

* gazelle

* finally working

* save slot

* fix lint and constant
2018-11-21 10:00:36 -08:00

35 lines
707 B
Go

package db
import (
"github.com/boltdb/bolt"
)
// GetSimulatorSlot returns the last saved simulator slot
// from the disk.
func (db *BeaconDB) GetSimulatorSlot() (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)
})
}