receiver

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrAccessDenied must be used when the requester does not have access rights for the document requested
	ErrAccessDenied = errors.Error("requester does not have access")

	// ErrInvalidAccessType must be used when the access type found in the request is invalid
	ErrInvalidAccessType = errors.Error("invalid access type")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler implements protocol message handlers

func New

func New(
	config config.Service,
	handshakeValidator ValidatorGroup,
	docSrv documents.Service,
	tokenRegistry documents.TokenRegistry,
	srvDID identity.Service) *Handler

New returns an implementation of P2PServiceServer

func (*Handler) GetDocument

func (srv *Handler) GetDocument(ctx context.Context, docReq *p2ppb.GetDocumentRequest, requester identity.DID) (*p2ppb.GetDocumentResponse, error)

GetDocument receives document identifier and retrieves the corresponding CoreDocument from the repository

func (*Handler) HandleGetDocument

func (srv *Handler) HandleGetDocument(ctx context.Context, peer peer.ID, protoc protocol.ID, msg *p2ppb.Envelope) (*pb.P2PEnvelope, error)

HandleGetDocument handles HandleGetDocument message

func (*Handler) HandleInterceptor

func (srv *Handler) HandleInterceptor(ctx context.Context, peer peer.ID, protoc protocol.ID, msg *pb.P2PEnvelope) (*pb.P2PEnvelope, error)

HandleInterceptor acts as main entry point for all message types, routes the request to the correct handler

func (*Handler) HandleRequestDocumentSignature

func (srv *Handler) HandleRequestDocumentSignature(ctx context.Context, peer peer.ID, protoc protocol.ID, msg *p2ppb.Envelope) (*pb.P2PEnvelope, error)

HandleRequestDocumentSignature handles the RequestDocumentSignature message

func (*Handler) HandleSendAnchoredDocument

func (srv *Handler) HandleSendAnchoredDocument(ctx context.Context, peer peer.ID, protoc protocol.ID, msg *p2ppb.Envelope) (*pb.P2PEnvelope, error)

HandleSendAnchoredDocument handles the SendAnchoredDocument message

func (*Handler) RequestDocumentSignature

func (srv *Handler) RequestDocumentSignature(ctx context.Context, sigReq *p2ppb.SignatureRequest, collaborator identity.DID) (*p2ppb.SignatureResponse, error)

RequestDocumentSignature signs the received document and returns the signature of the signingRoot document signing root will be recalculated and verified Existing signatures on the document will be verified document will be stored to the repository for state management

func (*Handler) SendAnchoredDocument

func (srv *Handler) SendAnchoredDocument(ctx context.Context, docReq *p2ppb.AnchorDocumentRequest, collaborator identity.DID) (*p2ppb.AnchorDocumentResponse, error)

SendAnchoredDocument receives a new anchored document, validates and updates the document in DB

type Validator

type Validator interface {
	// Validate validates p2p requests
	Validate(header *p2ppb.Header, centID *identity.DID, peerID *libp2pPeer.ID) error
}

Validator defines method that must be implemented by any validator type.

type ValidatorFunc

type ValidatorFunc func(header *p2ppb.Header, centID *identity.DID, peerID *libp2pPeer.ID) error

ValidatorFunc implements Validator and can be used as a adaptor for functions with specific function signature

func (ValidatorFunc) Validate

func (vf ValidatorFunc) Validate(header *p2ppb.Header, centID *identity.DID, peerID *libp2pPeer.ID) error

Validate passes the arguments to the underlying validator function and returns the results

type ValidatorGroup

type ValidatorGroup []Validator

ValidatorGroup implements Validator for validating a set of validators.

func HandshakeValidator

func HandshakeValidator(networkID uint32, idService identity.Service) ValidatorGroup

HandshakeValidator validates the p2p handshake details

func (ValidatorGroup) Validate

func (group ValidatorGroup) Validate(header *p2ppb.Header, centID *identity.DID, peerID *libp2pPeer.ID) (errs error)

Validate will execute all group specific atomic validations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL