refactor: add constant for max Transaction size

This commit is contained in:
Michael Vines 2018-11-27 18:05:23 -08:00
parent f120ef21ee
commit aee383eaec
2 changed files with 7 additions and 3 deletions

View File

@ -23,7 +23,6 @@ export class Loader {
*/
programId: PublicKey;
/**
* Amount of program data placed in each load Transaction
*/

View File

@ -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;
}