2019-01-28 15:40:40 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2019-02-06 16:20:38 +00:00
|
|
|
pbp2p "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
2019-01-28 15:40:40 +00:00
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/rpc/v1"
|
|
|
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AttesterServer defines a server implementation of the gRPC Attester service,
|
|
|
|
// providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks.
|
|
|
|
type AttesterServer struct {
|
2019-01-31 18:54:24 +00:00
|
|
|
operationService operationService
|
2019-01-28 15:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AttestHead is a function called by an attester in a sharding validator to vote
|
|
|
|
// on a block via an attestation object as defined in the Ethereum Serenity specification.
|
2019-02-06 16:20:38 +00:00
|
|
|
func (as *AttesterServer) AttestHead(ctx context.Context, att *pbp2p.Attestation) (*pb.AttestResponse, error) {
|
|
|
|
h, err := hashutil.HashProto(att)
|
2019-01-28 15:40:40 +00:00
|
|
|
if err != nil {
|
2019-01-28 19:41:04 +00:00
|
|
|
return nil, fmt.Errorf("could not hash attestation: %v", err)
|
2019-01-28 15:40:40 +00:00
|
|
|
}
|
|
|
|
// Relays the attestation to chain service.
|
2019-02-06 16:20:38 +00:00
|
|
|
as.operationService.IncomingAttFeed().Send(att)
|
2019-01-28 15:40:40 +00:00
|
|
|
return &pb.AttestResponse{AttestationHash: h[:]}, nil
|
|
|
|
}
|
2019-02-06 16:20:38 +00:00
|
|
|
|
|
|
|
// AttestationInfoAtSlot --
|
|
|
|
//
|
|
|
|
// TODO(#1505): WIP.
|
|
|
|
func (as *AttesterServer) AttestationInfoAtSlot(ctx context.Context, req *pb.AttestationInfoRequest) (*pb.AttestationInfoResponse, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// CrosslinkCommitteesAtSlot --
|
|
|
|
//
|
|
|
|
// TODO(#1505): WIP.
|
|
|
|
func (as *AttesterServer) CrosslinkCommitteesAtSlot(ctx context.Context, req *pb.CrosslinkCommitteeRequest) (*pb.CrosslinkCommitteeResponse, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|