fn update_blocks_state<T: Transport>(
        &mut self,
        contract: &(ethabi::Contract, Contract<T>),
        logs: &[Log],
    ) -> bool {
        if logs.is_empty() {
            return false;
        }

        let block_verified_topic = contract
            .0
            .event("BlockVerification")
            .expect("Main contract abi error")
            .signature();
        let block_comitted_topic = contract
            .0
            .event("BlockCommit")
            .expect("Main contract abi error")
            .signature();
        let reverted_topic = contract
            .0
            .event("BlocksRevert")
            .expect("Main contract abi error")
            .signature();

        for log in logs {
            let topic = log.topics[0];
            assert!(log.topics.len() >= 2, "Cant get enouth topics from event");

            // Remove reverted committed blocks first
            if topic == reverted_topic {
                assert_eq!(
                    log.topics.len(),
                    3,
                    "Cant get enouth topics from reverted event"
                );
                let committed_total = U256::from(log.topics[2].as_bytes()).as_u32();
                let mut i = 0;
                while i != self.committed_events.len() {
                    if self.committed_events[i].block_num > committed_total {
                        self.committed_events.remove(i);
                    } else {
                        i += 1;
                    }
                }
            }

            // Go into new blocks
            let mut block: BlockEvent = BlockEvent {
                block_num: 0,
                transaction_hash: H256::zero(),
                block_type: EventType::Committed,
            };

            let tx_hash = log
                .transaction_hash
                .expect("There are no tx hash in block event");
            let block_num = log.topics[1];

            block.block_num = U256::from(block_num.as_bytes()).as_u32();
            block.transaction_hash = tx_hash;

            if topic == block_verified_topic {
                block.block_type = EventType::Verified;
                self.verified_events.push(block);
            } else if topic == block_comitted_topic {
                self.committed_events.push(block);
            }
        }
        true
    }
/// Updates committed and verified blocks state by extending their arrays
/// Returns flag that indicates if there are any logs
///
/// # Arguments
///
/// * `contract` - Specified contract
/// * `logs` - Block events with their info
///
Updates committed and verified blocks state by extending their arrays
Returns flag that indicates if there are any logs
Updates committed and verified blocks state by extending their arrays Returns flag that indicates if there are any logs
fn update_blocks_state<T: Transport>(
        &mut self,
        contract: &(ethabi::Contract, Contract<T>),
        logs: &[Log],
    ) -> bool {
        if logs.is_empty() {
            return false;
        }
        let block_verified_topic = contract
            .0
            .event("BlockVerification")
            .expect("Main contract abi error")
            .signature();
        let block_comitted_topic = contract
            .0
            .event("BlockCommit")
            .expect("Main contract abi error")
            .signature();
        let reverted_topic = contract
            .0
            .event("BlocksRevert")
            .expect("Main contract abi error")
            .signature();
        for log in logs {
            let topic = log.topics[0];
            assert!(log.topics.len() >= 2, "Cant get enouth topics from event");
            // Remove reverted committed blocks first
            if topic == reverted_topic {
                assert_eq!(
                    log.topics.len(),
                    3,
                    "Cant get enouth topics from reverted event"
                );
                let committed_total = U256::from(log.topics[2].as_bytes()).as_u32();
                let mut i = 0;
                while i != self.committed_events.len() {
                    if self.committed_events[i].block_num > committed_total {
                        self.committed_events.remove(i);
                    } else {
                        i += 1;
                    }
                }
            }
            // Go into new blocks
            let mut block: BlockEvent = BlockEvent {
                block_num: 0,
                transaction_hash: H256::zero(),
                block_type: EventType::Committed,
            };
            let tx_hash = log
                .transaction_hash
                .expect("There are no tx hash in block event");
            let block_num = log.topics[1];
            block.block_num = U256::from(block_num.as_bytes()).as_u32();
            block.transaction_hash = tx_hash;
            if topic == block_verified_topic {
                block.block_type = EventType::Verified;
                self.verified_events.push(block);
            } else if topic == block_comitted_topic {
                self.committed_events.push(block);
            }
        }
        true
    }
fn update_blocks_state < T : Transport > ( & mut self , contract : & ( ethabi :: Contract , Contract < T > ) , logs : & [ Log ] , ) -> bool { if logs . is_empty ( ) { return false ; } let block_verified_topic = contract . 0 . event ( " " ) . expect ( " " ) . signature ( ) ; let block_comitted_topic = contract . 0 . event ( " " ) . expect ( " " ) . signature ( ) ; let reverted_topic = contract . 0 . event ( " " ) . expect ( " " ) . signature ( ) ; for log in logs { let topic = log . topics [ 0 ] ; assert ! ( log topics len ( ) 2 " " ) ; // Remove reverted committed blocks first if topic == reverted_topic { assert_eq ! ( log topics len ( ) 3 " " ) ; let committed_total = U256 :: from ( log . topics [ 2 ] . as_bytes ( ) ) . as_u32 ( ) ; let mut i = 0 ; while i != self . committed_events . len ( ) { if self . committed_events [ i ] . block_num > committed_total { self . committed_events . remove ( i ) ; } else { i += 1 ; } } } // Go into new blocks let mut block : BlockEvent = BlockEvent { block_num : 0 , transaction_hash : H256 :: zero ( ) , block_type : EventType :: Committed , } ; let tx_hash = log . transaction_hash . expect ( " " ) ; let block_num = log . topics [ 1 ] ; block . block_num = U256 :: from ( block_num . as_bytes ( ) ) . as_u32 ( ) ; block . transaction_hash = tx_hash ; if topic == block_verified_topic { block . block_type = EventType :: Verified ; self . verified_events . push ( block ) ; } else if topic == block_comitted_topic { self . committed_events . push ( block ) ; } } true }
Updates committed and verified blocks state by extending their arrays
Returns flag that indicates if there are any logs
Updates committed and verified blocks state by extending their arrays Returns flag that indicates if there are any logs
&mut self
contract
&(ethabi::Contract, Contract<T>)
logs
&[Log]