@@ -18,13 +18,11 @@ use common_logger::{json, log};
1818use common_merkle:: TrieMerkle ;
1919use protocol:: traits:: { ConsensusAdapter , Context , MessageTarget , NodeInfo } ;
2020use protocol:: types:: {
21- Block , Bytes , ExecResp , Hash , Hasher , Hex , Log , MerkleRoot , Metadata , Proof , Proposal , Receipt ,
22- SignedTransaction , ValidatorExtend , BASE_FEE_PER_GAS , MAX_BLOCK_GAS_LIMIT , RLP_NULL , U256 ,
21+ Block , Bytes , ExecResp , Hash , Hasher , Hex , Metadata , Proof , Proposal , SignedTransaction ,
22+ ValidatorExtend , BASE_FEE_PER_GAS , MAX_BLOCK_GAS_LIMIT , RLP_NULL ,
2323} ;
2424use protocol:: { async_trait, tokio:: sync:: Mutex as AsyncMutex , ProtocolError , ProtocolResult } ;
2525
26- use core_executor:: logs_bloom;
27-
2826use crate :: message:: {
2927 END_GOSSIP_AGGREGATED_VOTE , END_GOSSIP_SIGNED_CHOKE , END_GOSSIP_SIGNED_PROPOSAL ,
3028 END_GOSSIP_SIGNED_VOTE ,
@@ -591,13 +589,7 @@ impl<Adapter: ConsensusAdapter + 'static> ConsensusEngine<Adapter> {
591589 let block_number = block. header . number ;
592590 let block_hash = block. hash ( ) ;
593591
594- let ( receipts, _logs) = generate_receipts_and_logs (
595- block_number,
596- block_hash,
597- block. header . state_root ,
598- & txs,
599- & resp,
600- ) ;
592+ let ( receipts, _logs) = block. generate_receipts_and_logs ( & txs, & resp) ;
601593
602594 common_apm:: metrics:: consensus:: ENGINE_ROUND_GAUGE . set ( proof. round as i64 ) ;
603595
@@ -746,43 +738,6 @@ fn validate_timestamp(
746738 true
747739}
748740
749- pub fn generate_receipts_and_logs (
750- block_number : u64 ,
751- block_hash : Hash ,
752- state_root : MerkleRoot ,
753- txs : & [ SignedTransaction ] ,
754- resp : & ExecResp ,
755- ) -> ( Vec < Receipt > , Vec < Vec < Log > > ) {
756- let mut log_index = 0 ;
757- let receipts = txs
758- . iter ( )
759- . enumerate ( )
760- . zip ( resp. tx_resp . iter ( ) )
761- . map ( |( ( idx, tx) , res) | {
762- let receipt = Receipt {
763- tx_hash : tx. transaction . hash ,
764- block_number,
765- block_hash,
766- tx_index : idx as u32 ,
767- state_root,
768- used_gas : U256 :: from ( res. gas_used ) ,
769- logs_bloom : logs_bloom ( res. logs . iter ( ) ) ,
770- logs : res. logs . clone ( ) ,
771- log_index,
772- code_address : res. code_address ,
773- sender : tx. sender ,
774- ret : res. exit_reason . clone ( ) ,
775- removed : res. removed ,
776- } ;
777- log_index += res. logs . len ( ) as u32 ;
778- receipt
779- } )
780- . collect :: < Vec < _ > > ( ) ;
781- let logs = receipts. iter ( ) . map ( |r| r. logs . clone ( ) ) . collect :: < Vec < _ > > ( ) ;
782-
783- ( receipts, logs)
784- }
785-
786741fn gauge_txs_len ( proposal : & Proposal ) {
787742 common_apm:: metrics:: consensus:: ENGINE_ORDER_TX_GAUGE . set ( proposal. tx_hashes . len ( ) as i64 ) ;
788743}
0 commit comments