mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
d143187b7e
* include fixes * rev * logrus * tests for query sync status and chain head * begin tests for indexed atts * test passing for requesting historical atts * Update slasher/beaconclient/chain_data_test.go * Update slasher/beaconclient/historical_data_retrieval.go * lint * fixed up wanted vs receied * fix mock * gazelle * fix broken build * tests pass * dep * gaz * add dep * tests pass Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package beaconclient
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"go.opencensus.io/trace"
|
|
)
|
|
|
|
// subscribeDetectedProposerSlashings subscribes to an event feed for
|
|
// slashing objects from the slasher runtime. Upon receiving
|
|
// a proposer slashing from the feed, we submit the object to the
|
|
// connected beacon node via a client RPC.
|
|
func (bs *Service) subscribeDetectedProposerSlashings(ctx context.Context, ch chan *ethpb.ProposerSlashing) {
|
|
ctx, span := trace.StartSpan(ctx, "beaconclient.submitProposerSlashing")
|
|
defer span.End()
|
|
sub := bs.proposerSlashingsFeed.Subscribe(ch)
|
|
defer sub.Unsubscribe()
|
|
for {
|
|
select {
|
|
case slashing := <-ch:
|
|
if _, err := bs.beaconClient.SubmitProposerSlashing(ctx, slashing); err != nil {
|
|
log.Error(err)
|
|
}
|
|
case <-sub.Err():
|
|
log.Error("Subscriber closed, exiting goroutine")
|
|
return
|
|
case <-ctx.Done():
|
|
log.Error("Context canceled")
|
|
return
|
|
}
|
|
}
|
|
}
|
|
|
|
// subscribeDetectedAttesterSlashings subscribes to an event feed for
|
|
// slashing objects from the slasher runtime. Upon receiving an
|
|
// attester slashing from the feed, we submit the object to the
|
|
// connected beacon node via a client RPC.
|
|
func (bs *Service) subscribeDetectedAttesterSlashings(ctx context.Context, ch chan *ethpb.AttesterSlashing) {
|
|
ctx, span := trace.StartSpan(ctx, "beaconclient.submitAttesterSlashing")
|
|
defer span.End()
|
|
sub := bs.attesterSlashingsFeed.Subscribe(ch)
|
|
defer sub.Unsubscribe()
|
|
for {
|
|
select {
|
|
case slashing := <-ch:
|
|
if _, err := bs.beaconClient.SubmitAttesterSlashing(ctx, slashing); err != nil {
|
|
log.Error(err)
|
|
}
|
|
case <-sub.Err():
|
|
log.Error("Subscriber closed, exiting goroutine")
|
|
return
|
|
case <-ctx.Done():
|
|
log.Error("Context canceled")
|
|
return
|
|
}
|
|
}
|
|
}
|