github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/violations_consumer.go (about)

     1  package network
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  	"github.com/onflow/flow-go/network/channels"
     6  	"github.com/onflow/flow-go/network/message"
     7  )
     8  
     9  // ViolationsConsumer logs reported slashing violation errors and reports those violations as misbehavior's to the ALSP
    10  // misbehavior report manager. Any errors encountered while reporting the misbehavior are considered irrecoverable and
    11  // will result in a fatal level log.
    12  type ViolationsConsumer interface {
    13  	// OnUnAuthorizedSenderError logs an error for unauthorized sender error.
    14  	OnUnAuthorizedSenderError(violation *Violation)
    15  
    16  	// OnUnknownMsgTypeError logs an error for unknown message type error.
    17  	OnUnknownMsgTypeError(violation *Violation)
    18  
    19  	// OnInvalidMsgError logs an error for messages that contained payloads that could not
    20  	// be unmarshalled into the message type denoted by message code byte.
    21  	OnInvalidMsgError(violation *Violation)
    22  
    23  	// OnSenderEjectedError logs an error for sender ejected error.
    24  	OnSenderEjectedError(violation *Violation)
    25  
    26  	// OnUnauthorizedUnicastOnChannel logs an error for messages unauthorized to be sent via unicast.
    27  	OnUnauthorizedUnicastOnChannel(violation *Violation)
    28  
    29  	// OnUnauthorizedPublishOnChannel logs an error for messages unauthorized to be sent via pubsub.
    30  	OnUnauthorizedPublishOnChannel(violation *Violation)
    31  
    32  	// OnUnexpectedError logs an error for unknown errors.
    33  	OnUnexpectedError(violation *Violation)
    34  }
    35  
    36  type Violation struct {
    37  	Identity *flow.Identity
    38  	PeerID   string
    39  	OriginID flow.Identifier
    40  	MsgType  string
    41  	Channel  channels.Channel
    42  	Protocol message.ProtocolType
    43  	Err      error
    44  }