From 152bb3088968bf0f350ff9dc3d16b0d2ee406cfe Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 18 Jan 2019 12:31:39 -0300 Subject: [PATCH] limit number of transactions when building blocks (#91) --- polkadot/consensus/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polkadot/consensus/src/lib.rs b/polkadot/consensus/src/lib.rs index 2d4876db20..e15aa77a30 100644 --- a/polkadot/consensus/src/lib.rs +++ b/polkadot/consensus/src/lib.rs @@ -628,6 +628,8 @@ impl CreateProposal where use client::block_builder::BlockBuilder; use runtime_primitives::traits::{Hash as HashT, BlakeTwo256}; + const MAX_TRANSACTIONS: usize = 40; + let inherent_data = InherentData { timestamp: self.believed_minimum_timestamp, parachains: candidates, @@ -648,7 +650,7 @@ impl CreateProposal where let mut pending_size = 0; let ready_iter = self.transaction_pool.ready(); - for ready in ready_iter { + for ready in ready_iter.take(MAX_TRANSACTIONS) { let encoded_size = ready.data.encode().len(); if pending_size + encoded_size >= MAX_TRANSACTIONS_SIZE { break