From aee383eaec04bae4e0514bddba368a09b178bc69 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 27 Nov 2018 18:05:23 -0800 Subject: [PATCH] refactor: add constant for max Transaction size --- web3.js/src/loader.js | 1 - web3.js/src/transaction.js | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/web3.js/src/loader.js b/web3.js/src/loader.js index b2167434f7..5c93f4388a 100644 --- a/web3.js/src/loader.js +++ b/web3.js/src/loader.js @@ -23,7 +23,6 @@ export class Loader { */ programId: PublicKey; - /** * Amount of program data placed in each load Transaction */ diff --git a/web3.js/src/transaction.js b/web3.js/src/transaction.js index 00916f940b..f5828e8d73 100644 --- a/web3.js/src/transaction.js +++ b/web3.js/src/transaction.js @@ -19,6 +19,11 @@ export type TransactionSignature = string; */ export type TransactionId = string; +/** + * Maximum over-the-wire size of a Transaction + */ +export const PACKET_DATA_SIZE = 512; + /** * List of TransactionInstruction object fields that may be initialized at construction * @@ -290,8 +295,8 @@ export class Transaction { }); signData.copy(wireTransaction, 8 + signatures.length * 64); invariant( - wireTransaction.length < 512, - `${wireTransaction.length}, ${signatures.length}`, + wireTransaction.length <= PACKET_DATA_SIZE, + `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`, ); return wireTransaction; }