github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/disallow.go (about) 1 package network 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 ) 6 7 // DisallowListedCause is a type representing the cause of disallow listing. A remote node may be disallow-listed by the 8 // current node for a variety of reasons. This type is used to represent the reason for disallow-listing, so that if 9 // a node is disallow-listed for reasons X and Y, allow-listing it back for reason X does not automatically allow-list 10 // it for reason Y. 11 type DisallowListedCause string 12 13 func (c DisallowListedCause) String() string { 14 return string(c) 15 } 16 17 const ( 18 // DisallowListedCauseAdmin is the cause of disallow-listing a node by an admin command. 19 DisallowListedCauseAdmin DisallowListedCause = "disallow-listed-admin" 20 // DisallowListedCauseAlsp is the cause of disallow-listing a node by the ALSP (Application Layer Spam Prevention). 21 DisallowListedCauseAlsp DisallowListedCause = "disallow-listed-alsp" 22 ) 23 24 // DisallowListingUpdate is a notification of a new disallow list update, it contains a list of Flow identities that 25 // are now disallow listed for a specific reason. 26 type DisallowListingUpdate struct { 27 FlowIds flow.IdentifierList 28 Cause DisallowListedCause 29 } 30 31 // AllowListingUpdate is a notification of a new allow list update, it contains a list of Flow identities that 32 // are now allow listed for a specific reason, i.e., their disallow list entry for that reason is removed. 33 type AllowListingUpdate struct { 34 FlowIds flow.IdentifierList 35 Cause DisallowListedCause 36 } 37 38 // DisallowListNotificationConsumer is an interface for consuming disallow/allow list update notifications. 39 type DisallowListNotificationConsumer interface { 40 // OnDisallowListNotification is called when a new disallow list update notification is distributed. 41 // Any error on consuming an event must be handled internally. 42 // The implementation must be concurrency safe. 43 OnDisallowListNotification(*DisallowListingUpdate) 44 45 // OnAllowListNotification is called when a new allow list update notification is distributed. 46 // Any error on consuming an event must be handled internally. 47 // The implementation must be concurrency safe. 48 OnAllowListNotification(*AllowListingUpdate) 49 }