/// Adds propose from other node. Returns `ProposeState` if it is a new propose.
Adds propose from other node. Returns `ProposeState` if it is a new propose.
Adds propose from other node . Returns ` ProposeState ` if it is a new propose .
pub(super) fn add_propose<T: RawAccess>(
        &mut self,
        msg: Verified<Propose>,
        transactions: &MapIndex<T, Hash, Verified<AnyTx>>,
        transaction_pool: &KeySetIndex<T, Hash>,
    ) -> Result<&ProposeState, failure::Error> {
        let propose_hash = msg.object_hash();
        match self.proposes.entry(propose_hash) {
            Entry::Occupied(..) => bail!("Propose already found"),
            Entry::Vacant(e) => {
                let mut is_valid = true;
                let mut unknown_txs = HashSet::new();
                for hash in &msg.payload().transactions {
                    if self.tx_cache.contains_key(hash) {
                        // Tx with `hash` is  not committed yet.
                        continue;
                    }
                    if transactions.contains(hash) {
                        if !transaction_pool.contains(hash) {
                            bail!(
                                "Received propose with already \
                                 committed transaction"
                            )
                        }
                    } else if self.invalid_txs.contains(hash) {
                        // If the propose contains an invalid transaction,
                        // we don't stop processing, since we expect this propose to
                        // be declined by the consensus rules.
                        error!("Received propose with transaction known as invalid");
                        is_valid = false;
                    } else {
                        unknown_txs.insert(*hash);
                    }
                }
                for tx in &unknown_txs {
                    self.unknown_txs
                        .entry(*tx)
                        .or_insert_with(Vec::new)
                        .push(propose_hash);
                }
                Ok(e.insert(ProposeState {
                    propose: msg,
                    unknown_txs,
                    block_hash: None,
                    is_saved: false,
                    is_valid,
                }))
            }
        }
    }
pub ( super ) fn add_propose < T : RawAccess > ( & mut self , msg : Verified < Propose > , transactions : & MapIndex < T , Hash , Verified < AnyTx > > , transaction_pool : & KeySetIndex < T , Hash > , ) -> Result < & ProposeState , failure :: Error > { let propose_hash = msg . object_hash ( ) ; match self . proposes . entry ( propose_hash ) { Entry :: Occupied ( .. ) => bail ! ( " " ) , Entry :: Vacant ( e ) => { let mut is_valid = true ; let mut unknown_txs = HashSet :: new ( ) ; for hash in & msg . payload ( ) . transactions { if self . tx_cache . contains_key ( hash ) { // Tx with `hash` is  not committed yet. continue ; } if transactions . contains ( hash ) { if ! transaction_pool . contains ( hash ) { bail ! ( " \
 " ) } } else if self . invalid_txs . contains ( hash ) { // If the propose contains an invalid transaction, // we don't stop processing, since we expect this propose to // be declined by the consensus rules. error ! ( " " ) ; is_valid = false ; } else { unknown_txs . insert ( * hash ) ; } } for tx in & unknown_txs { self . unknown_txs . entry ( * tx ) . or_insert_with ( Vec :: new ) . push ( propose_hash ) ; } Ok ( e . insert ( ProposeState { propose : msg , unknown_txs , block_hash : None , is_saved : false , is_valid , } ) ) } } }
Adds propose from other node.
Adds propose from other node .
&mut self
msg
Verified<Propose>
transactions
&MapIndex<T, Hash, Verified<AnyTx>>
transaction_pool
&KeySetIndex<T, Hash>