github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/alsp/internal/reported_misbehavior_work.go (about) 1 package internal 2 3 import ( 4 "github.com/onflow/flow-go/model/flow" 5 "github.com/onflow/flow-go/network" 6 "github.com/onflow/flow-go/network/channels" 7 ) 8 9 const NonceSize = 8 10 11 // ReportedMisbehaviorWork is an internal data structure for "temporarily" storing misbehavior reports in the queue 12 // till they are processed by the worker. 13 type ReportedMisbehaviorWork struct { 14 // Channel is the channel that the misbehavior report is about. 15 Channel channels.Channel 16 17 // OriginId is the ID of the peer that the misbehavior report is about. 18 OriginId flow.Identifier 19 20 // Reason is the reason of the misbehavior. 21 Reason network.Misbehavior 22 23 // Nonce is a random nonce value that is used to make the key of the struct unique in the queue even when 24 // the same misbehavior report is reported multiple times. This is needed as we expect the same misbehavior report 25 // to be reported multiple times when an attack persists for a while. We don't want to deduplicate the misbehavior 26 // reports in the queue as we want to penalize the misbehaving node for each report. 27 Nonce [NonceSize]byte 28 29 // Penalty is the penalty value of the misbehavior. 30 // We use `rlp:"-"` to ignore this field when serializing the struct to RLP to determine the key of this struct 31 // when storing in the queue. Hence, the penalty value does "not" contribute to the key for storing in the queue. 32 // As RLP encoding does not support float64, we cannot use this field as the key of the 33 // struct. As we use a random nonce value for the key of the struct, we can be sure that we will not have a collision 34 // in the queue, and duplicate reports will be accepted with unique keys. 35 Penalty float64 `rlp:"-"` 36 }