/// The method reacts in a malicious way when receiving a chunk
/// request from a certain peer.
///
/// The malicious flags define the actual behavior, which may
/// either drop the request, respond that the artifact could not
/// be found, sending too many artifacts back, or sending invalid
/// artifacts.
The method reacts in a malicious way when receiving a chunk
request from a certain peer.

The malicious flags define the actual behavior, which may
either drop the request, respond that the artifact could not
be found, sending too many artifacts back, or sending invalid
artifacts.
The method reacts in a malicious way when receiving a chunk request from a certain peer . The malicious flags define the actual behavior which may either drop the request respond that the artifact could not be found sending too many artifacts back or sending invalid artifacts .
fn malicious_behavior_on_chunk_request(&self, gossip_chunk: GossipChunk, node_id: NodeId) {
        if self.malicious_flags.maliciously_gossip_drop_requests {
            warn!(self.log, "Malicious behavior: dropping requests");
        } else if self.malicious_flags.maliciously_gossip_artifact_not_found {
            warn!(self.log, "Malicious behavior: artifact not found");
            let chunk_not_found = GossipChunk {
                artifact_id: gossip_chunk.artifact_id,
                chunk_id: gossip_chunk.chunk_id,
                artifact_chunk: Err(P2PError {
                    p2p_error_code: P2PErrorCode::NotFound,
                }),
            };
            self.download_manager
                .send_chunk_to_peer(chunk_not_found, node_id);
        } else if self.malicious_flags.maliciously_gossip_send_many_artifacts {
            warn!(self.log, "Malicious behavior: sending too many artifacts");
            for _n in 1..10000 {
                self.download_manager
                    .send_chunk_to_peer(gossip_chunk.clone(), node_id);
            }
        } else if self
            .malicious_flags
            .maliciously_gossip_send_invalid_artifacts
        {
            warn!(self.log, "Malicious behavior: sending invalid artifacts");
            let artifact_id = gossip_chunk.artifact_id;
            let chunk_id = gossip_chunk.chunk_id;
            let artifact_chunk_data = ArtifactChunkData::SemiStructuredChunkData([].to_vec());
            let artifact_chunk = Ok(ArtifactChunk {
                chunk_id,
                witness: Default::default(),
                artifact_chunk_data,
            });
            let invalid_chunk = GossipChunk {
                artifact_id,
                chunk_id,
                artifact_chunk,
            };
            self.download_manager
                .send_chunk_to_peer(invalid_chunk, node_id);
        } else {
            warn!(self.log, "Malicious behavior: This should never happen!");
        }
    }
fn malicious_behavior_on_chunk_request ( & self , gossip_chunk : GossipChunk , node_id : NodeId ) { if self . malicious_flags . maliciously_gossip_drop_requests { warn ! ( self log " " ) ; } else if self . malicious_flags . maliciously_gossip_artifact_not_found { warn ! ( self log " " ) ; let chunk_not_found = GossipChunk { artifact_id : gossip_chunk . artifact_id , chunk_id : gossip_chunk . chunk_id , artifact_chunk : Err ( P2PError { p2p_error_code : P2PErrorCode :: NotFound , } ) , } ; self . download_manager . send_chunk_to_peer ( chunk_not_found , node_id ) ; } else if self . malicious_flags . maliciously_gossip_send_many_artifacts { warn ! ( self log " " ) ; for _n in 1 .. 10000 { self . download_manager . send_chunk_to_peer ( gossip_chunk . clone ( ) , node_id ) ; } } else if self . malicious_flags . maliciously_gossip_send_invalid_artifacts { warn ! ( self log " " ) ; let artifact_id = gossip_chunk . artifact_id ; let chunk_id = gossip_chunk . chunk_id ; let artifact_chunk_data = ArtifactChunkData :: SemiStructuredChunkData ( [ ] . to_vec ( ) ) ; let artifact_chunk = Ok ( ArtifactChunk { chunk_id , witness : Default :: default ( ) , artifact_chunk_data , } ) ; let invalid_chunk = GossipChunk { artifact_id , chunk_id , artifact_chunk , } ; self . download_manager . send_chunk_to_peer ( invalid_chunk , node_id ) ; } else { warn ! ( self log " " ) ; } }
The method reacts in a malicious way when receiving a chunk
request from a certain peer.
The method reacts in a malicious way when receiving a chunk request from a certain peer .
&self
gossip_chunk
GossipChunk
node_id
NodeId