mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-28 14:17:17 +00:00
612bb38077
* Fix assignments bug where validators don't retry for assignments on failure * synch only please * trying to fix state issues * trying random stuff * do not explode * use ctx * working build, failing tests * broadcast local addrs as well as relay addrs * fixed p2p tests, more tests to fix still * another test fixed, log warning instead of throw error * Fix last tests * godoc * add test for broadcast in apply fork choiec * remove unneeded code * remove tracer adapter, not needed * remove extra stuff * remove any * revert addr_factory * revert addr_factory * Revert "revert addr_factory" This reverts commit e93fb706494a1070158b8db31e67146d6b0648ad. * Revert "revert addr_factory" This reverts commit dedaa405559cc818698870c4e4570953367f1e3c. * revert removal of this code * unused param
44 lines
1017 B
Go
44 lines
1017 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/boltdb/bolt"
|
|
"github.com/gogo/protobuf/proto"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// SaveExit puts the exit request into the beacon chain db.
|
|
func (db *BeaconDB) SaveExit(ctx context.Context, exit *pb.VoluntaryExit) error {
|
|
ctx, span := trace.StartSpan(ctx, "beaconDB.SaveExit")
|
|
defer span.End()
|
|
|
|
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
|
|
}
|