mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
b86388410d
* begin reorder * move into beacon server * add proposer server * fix * add proposer server * wrap up rpc reorder * gazelle * lint fix * fix broken build
31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
package rpc
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
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 {
|
|
attestationService attestationService
|
|
}
|
|
|
|
// 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.
|
|
func (as *AttesterServer) AttestHead(ctx context.Context, req *pb.AttestRequest) (*pb.AttestResponse, error) {
|
|
enc, err := proto.Marshal(req.Attestation)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("could not marshal attestation: %v", err)
|
|
}
|
|
h := hashutil.Hash(enc)
|
|
// Relays the attestation to chain service.
|
|
as.attestationService.IncomingAttestationFeed().Send(req.Attestation)
|
|
|
|
return &pb.AttestResponse{AttestationHash: h[:]}, nil
|
|
}
|