prysm-pulse/beacon-chain/db/block_operations.go
terence tsao 8c04ced1a6 Name Changes to Align with V0.3 (#1621)
* fixed epoch_processing

* penalize->slash

* exit -> voluntary_exit

*  SEED_LOOKAHEAD -> MIN_SEED_LOOKAHED

* ENTRY_EXIT_DELAY -> ACTIVATION_EXIT_DELAY

* `INCLUDER_REWARD_QUOTIENT` -> `ATTESTATION_INCLUSION_REWARD_QUOTIEN`

* LatestIndexRoots -> LatestActiveIndexRoots

* `MIN_VALIDATOR_WITHDRAWAL_EPOCHS` -> `MIN_VALIDATOR_WITHDRAWAL_DELAY`

* MAX_WITHDRAWALS_PER_EPOCH -> MAX_EXIT_DEQUEUES_PER_EPOCH

* ETH1_DATA_VOTING_PERIOD -> EPOCHS_PER_ETH1_VOTING_PERIOD

* SLOT_DURATION -> SECONDS_PER_SLOT

* EPOCH_LENGTH -> SLOTS_PER_EPOCH

* SLOT_DURATION -> SECONDS_PER_SLOT take 2

* rest of the misc fixes for config name changes

* remove tools/bootnode/.!74296!bootnode.go

* `current_epoch_start_shard` -> `current_shuffling_start_shard`, `current_shuffling_epoch`, `current_shuffling_see`

* go fmt

* fixed comment

* updated pseudocode comments

* merged master
2019-02-18 10:52:16 -06:00

38 lines
883 B
Go

package db
import (
"github.com/boltdb/bolt"
"github.com/gogo/protobuf/proto"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/hashutil"
)
// SaveExit puts the exit request into the beacon chain db.
func (db *BeaconDB) SaveExit(exit *pb.VoluntaryExit) error {
hash, err := hashutil.HashProto(exit)
if err != nil {
return err
}
encodedExit, err := proto.Marshal(exit)
if err != nil {
return err
}
return db.update(func(tx *bolt.Tx) error {
a := tx.Bucket(blockOperationsBucket)
return a.Put(hash[:], encodedExit)
})
}
// HasExit checks if the exit request exists.
func (db *BeaconDB) HasExit(hash [32]byte) bool {
exists := false
if err := db.view(func(tx *bolt.Tx) error {
b := tx.Bucket(blockOperationsBucket)
exists = b.Get(hash[:]) != nil
return nil
}); err != nil {
return false
}
return exists
}