Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/lightclient/lightclient/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (l *LightClientServer) NotifyBeaconBlock(ctx context.Context, beaconBlock *
},
})
}
if err != nil {
return nil, err
}

return &lightrpc.NotificationStatus{
Status: 0,
Expand Down
50 changes: 3 additions & 47 deletions cmd/lightclient/sentinel/sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (s *Sentinel) GetPeersCount() int {
return len(s.host.Network().Peers())
}

func RunSentinelService(client lightrpc.LightclientClient, cfg *SentinelConfig) {
func RunSentinelService(client lightrpc.LightclientServer, cfg *SentinelConfig) {
ctx := context.Background()
sent, err := New(context.Background(), cfg)
if err != nil {
Expand Down Expand Up @@ -273,52 +273,8 @@ func RunSentinelService(client lightrpc.LightclientClient, cfg *SentinelConfig)
case pkt := <-sent.RecvGossip():
switch u := pkt.Packet.(type) {
case *lightrpc.SignedBeaconBlockBellatrix:
if _, err := client.NotifyBeaconBlock(context.Background(), u); err != nil {
panic(err)
}
}
}
}
}

func RunSentinelServiceInternally(client lightrpc.LightclientServer, cfg *SentinelConfig) {
ctx := context.Background()
sent, err := New(context.Background(), cfg)
if err != nil {
log.Error("error", "err", err)
return
}
if err := sent.Start(); err != nil {
log.Error("failed to start sentinel", "err", err)
return
}
gossip_topics := []GossipTopic{
BeaconBlockSsz,
LightClientFinalityUpdateSsz,
LightClientOptimisticUpdateSsz,
}
for _, v := range gossip_topics {
// now lets separately connect to the gossip topics. this joins the room
subscriber, err := sent.SubscribeGossip(v)
if err != nil {
log.Error("failed to start sentinel", "err", err)
}
// actually start the subscription, ala listening and sending packets to the sentinel recv channel
err = subscriber.Listen()
if err != nil {
log.Error("failed to start sentinel", "err", err)
}
}
log.Info("Sentinel started", "enr", sent.String())
for {
select {
case <-ctx.Done():
return
case pkt := <-sent.RecvGossip():
switch u := pkt.Packet.(type) {
case *lightrpc.SignedBeaconBlockBellatrix:
if _, err := client.NotifyBeaconBlock(context.Background(), u); err != nil {
panic(err)
if _, err := client.NotifyBeaconBlock(context.Background(), u); err != nil && err != context.Canceled {
log.Warn("Could not notify about new beacon block", "err", err)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
if err != nil {
return nil, err
}
go sentinel.RunSentinelServiceInternally(lightclientSrv, &sentinel.SentinelConfig{
go sentinel.RunSentinelService(lightclientSrv, &sentinel.SentinelConfig{
IpAddr: "127.0.0.1",
Port: 4000,
TCPPort: 4001,
Expand Down