From 41df7418f56bfb61a40e682681f7d2b96afa1d20 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Tue, 04 May 2021 09:24:26 +0000 Subject: [PATCH] perf: do not submit eth transactions with no logs --- --- a/pallets/nft/src/eth/log.rs +++ b/pallets/nft/src/eth/log.rs @@ -7,6 +7,9 @@ pub struct LogRecorder(RefCell, Vec)>>); impl LogRecorder { + pub fn is_empty(&self) -> bool { + self.0.borrow().is_empty() + } pub fn log(&self, topics: Vec, data: super::abi::AbiWriter) { self.0.borrow_mut().push((topics, data.finish())); } --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -2204,6 +2204,9 @@ } fn submit_logs(collection: CollectionHandle) -> DispatchResult { + if collection.logs.is_empty() { + return Ok(()) + } T::EthereumTransactionSender::submit_logs_transaction( eth::generate_transaction(collection.id, T::EthereumChainId::get()), collection.logs.retrieve_logs_for_contract(eth::collection_id_to_address(collection.id)), -- gitstuff