- if self.inputs.iter().any(|(serial_id, _)| *serial_id == msg.serial_id) {
- // The receiving node:
- // - MUST fail the negotiation if:
- // - the `serial_id` is already included in the transaction
- return Err(AbortReason::DuplicateSerialId);
- }
- let prev_outpoint = OutPoint { txid, vout: msg.prevtx_out };
- self.inputs.entry(msg.serial_id).or_insert_with(|| TxInputWithPrevOutput {
- input: TxIn {
- previous_output: prev_outpoint.clone(),
- sequence: Sequence(msg.sequence),
- ..Default::default()
+ match self.inputs.entry(msg.serial_id) {
+ hash_map::Entry::Occupied(_) => {
+ // The receiving node:
+ // - MUST fail the negotiation if:
+ // - the `serial_id` is already included in the transaction
+ Err(AbortReason::DuplicateSerialId)