Module com.hedera.hashgraph.sdk
Package com.hedera.hashgraph.sdk
Class ChunkedTransaction<T extends ChunkedTransaction<T>>
java.lang.Object
com.hedera.hashgraph.sdk.Executable<T,Transaction,TransactionResponse,TransactionResponse>
com.hedera.hashgraph.sdk.Transaction<T>
com.hedera.hashgraph.sdk.ChunkedTransaction<T>
- Direct Known Subclasses:
FileAppendTransaction,TopicMessageSubmitTransaction
A common base for file and topic message transactions.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Transaction
Transaction.SignableNodeTransactionBodyBytesNested classes/interfaces inherited from class com.hedera.hashgraph.sdk.Executable
Executable.GrpcRequest -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.google.protobuf.ByteStringThe transaction dataFields inherited from class com.hedera.hashgraph.sdk.Transaction
customFeeLimits, DEFAULT_AUTO_RENEW_PERIOD, defaultMaxTransactionFee, DUMMY_ACCOUNT_ID, DUMMY_TRANSACTION_ID, frozenBodyBuilder, innerSignedTransactions, outerTransactions, publicKeys, regenerateTransactionId, signers, sigPairLists, sourceTransactionBody, transactionIdsFields inherited from class com.hedera.hashgraph.sdk.Executable
attemptedAllNodes, blockingUnaryCall, grpcDeadline, logger, maxAttempts, maxBackoff, minBackoff, nodeAccountIds, nodes, random, RST_STREAM -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.ChunkedTransaction(TransactionBody txBody) Constructor.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddSignature(PublicKey publicKey, byte[] signature) Add a signature to the transaction.Get the body sizes for all chunks in a FileAppendTransaction.Execute this transaction or query with a timeoutexecuteAll(Client client) Execute this transaction or queryexecuteAll(Client client, Duration timeoutPerChunk) Execute this transaction or queryexecuteAllAsync(Client client) Execute this transaction or query asynchronously.executeAllAsync(Client client, Duration timeoutPerChunk) Execute this transaction or query asynchronously.voidexecuteAllAsync(Client client, Duration timeout, BiConsumer<List<TransactionResponse>, Throwable> callback) Execute this transaction or query asynchronously.voidexecuteAllAsync(Client client, Duration timeout, Consumer<List<TransactionResponse>> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.voidexecuteAllAsync(Client client, BiConsumer<List<TransactionResponse>, Throwable> callback) Execute this transaction or query asynchronously.voidexecuteAllAsync(Client client, Consumer<List<TransactionResponse>> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.executeAsync(Client client, Duration timeoutPerChunk) Execute this transaction or query asynchronously.Extract the list of all signers.Extract the list of transaction hashes.intRetrieve the chunk size.(package private) com.google.protobuf.ByteStringgetData()Extract the data.intRetrieve the maximum number of chunks.(package private) intThere must be at least one chunk.Extract list of account id and public keys.byte[]Extract a byte array of the transaction hash.Extract the list of account id and hash records.(package private) abstract voidonFreezeChunk(TransactionBody.Builder body, TransactionID initialTransactionId, int startIndex, int endIndex, int chunk, int total) A common base for file and topic message transactions.schedule()Extract the scheduled transaction.setChunkSize(int chunkSize) Assign the chunk size.(package private) TsetData(byte[] data) Assign the data via a byte array.(package private) TsetData(com.google.protobuf.ByteString data) Assign the data via a byte string.(package private) TAssign the data via a string.setMaxChunks(int maxChunks) Assign the max number of chunks.(package private) booleanShould the receipt be retrieved?(package private) voidwipeTransactionLists(int requiredChunks) Wipe / reset the transaction list.Methods inherited from class com.hedera.hashgraph.sdk.Transaction
addSignature, batchify, buildAllTransactions, buildTransaction, doSchedule, estimateFee, freeze, freezeWith, fromBytes, fromScheduledTransaction, generateTransactionIds, getBatchKey, getDefaultMaxTransactionFee, getExecutionState, getHighVolume, getMaxTransactionFee, getRegenerateTransactionId, getSignableNodeBodyBytesList, getSignaturesAtOffset, getTransactionBodySize, getTransactionId, getTransactionIdInternal, getTransactionMemo, getTransactionSize, getTransactionValidDuration, hash, isBatchedAndNotBatchTransaction, isFrozen, keyAlreadySigned, makeRequest, mapResponse, mapResponseStatus, onExecute, onExecuteAsync, onFreeze, onScheduled, regenerateTransactionId, requireNotFrozen, requireOneNodeAccountId, setBatchKey, setHighVolume, setMaxTransactionFee, setNodeAccountIds, setRegenerateTransactionId, setTransactionId, setTransactionMemo, setTransactionValidDuration, sign, signTransaction, signWith, signWithOperator, spawnBodyBuilder, toBytes, toString, validateChecksumsMethods inherited from class com.hedera.hashgraph.sdk.Executable
advanceRequest, checkNodeAccountIds, execute, executeAsync, executeAsync, executeAsync, executeAsync, executeAsync, getGrpcRequest, getMaxAttempts, getMaxBackoff, getMaxRetry, getMethodDescriptor, getMinBackoff, getNodeAccountIds, getNodeForExecute, grpcDeadline, logTransaction, mergeFromClient, setGrpcDeadline, setLogger, setMaxAttempts, setMaxBackoff, setMaxRetry, setMinBackoff, setNodesFromNodeAccountIds, setRequestListener, setResponseListener, shouldRetryExceptionally
-
Field Details
-
data
protected com.google.protobuf.ByteString dataThe transaction data
-
-
Constructor Details
-
ChunkedTransaction
ChunkedTransaction(LinkedHashMap<TransactionId, LinkedHashMap<AccountId, throws com.google.protobuf.InvalidProtocolBufferExceptionTransaction>> txs) Constructor.- Parameters:
txs- Compound list of transaction id's list of (AccountId, Transaction) records- Throws:
com.google.protobuf.InvalidProtocolBufferException- when there is an issue with the protobuf
-
ChunkedTransaction
ChunkedTransaction(TransactionBody txBody) Constructor.- Parameters:
txBody- protobuf TransactionBody
-
ChunkedTransaction
ChunkedTransaction()Constructor.
-
-
Method Details
-
getData
com.google.protobuf.ByteString getData()Extract the data.- Returns:
- the data
-
setData
Assign the data via a byte array.- Parameters:
data- the byte array- Returns:
this
-
setData
Assign the data via a byte string.- Parameters:
data- the byte string- Returns:
this
-
setData
Assign the data via a string.- Parameters:
text- the byte array- Returns:
this
-
getMaxChunks
public int getMaxChunks()Retrieve the maximum number of chunks.- Returns:
- the number of chunks
-
setMaxChunks
Assign the max number of chunks.- Parameters:
maxChunks- the number of chunks- Returns:
this
-
getChunkSize
public int getChunkSize()Retrieve the chunk size.- Returns:
- the chunk size
-
setChunkSize
Assign the chunk size.- Parameters:
chunkSize- the chunk size- Returns:
this
-
getTransactionHash
public byte[] getTransactionHash()Description copied from class:TransactionExtract a byte array of the transaction hash.- Overrides:
getTransactionHashin classTransaction<T extends ChunkedTransaction<T>>- Returns:
- the transaction hash
-
getTransactionHashPerNode
Description copied from class:TransactionExtract the list of account id and hash records.- Overrides:
getTransactionHashPerNodein classTransaction<T extends ChunkedTransaction<T>>- Returns:
- the list of account id and hash records
-
getAllTransactionHashesPerNode
Extract the list of transaction hashes.- Returns:
- the list of transaction hashes
-
addSignature
Description copied from class:TransactionAdd a signature to the transaction.- Overrides:
addSignaturein classTransaction<T extends ChunkedTransaction<T>>- Parameters:
publicKey- the public keysignature- the signature- Returns:
this
-
getSignatures
Description copied from class:TransactionExtract list of account id and public keys.- Overrides:
getSignaturesin classTransaction<T extends ChunkedTransaction<T>>- Returns:
- the list of account id and public keys
-
getAllSignatures
Extract the list of all signers.- Returns:
- the list of all signatures
-
execute
public TransactionResponse execute(Client client, Duration timeoutPerChunk) throws TimeoutException, PrecheckStatusException Description copied from class:ExecutableExecute this transaction or query with a timeout- Overrides:
executein classExecutable<T extends ChunkedTransaction<T>,Transaction, TransactionResponse, TransactionResponse> - Parameters:
client- The client with which this will be executed.timeoutPerChunk- The timeout after which the execution attempt will be cancelled.- Returns:
- Result of execution
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
executeAll
public List<TransactionResponse> executeAll(Client client) throws PrecheckStatusException, TimeoutException Execute this transaction or query- Parameters:
client- The client with which this will be executed.- Returns:
- Result of execution for each chunk
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
executeAll
public List<TransactionResponse> executeAll(Client client, Duration timeoutPerChunk) throws PrecheckStatusException, TimeoutException Execute this transaction or query- Parameters:
client- The client with which this will be executed.timeoutPerChunk- The timeout after which the execution attempt will be cancelled.- Returns:
- Result of execution for each chunk
- Throws:
TimeoutException- when the transaction times outPrecheckStatusException- when the precheck fails
-
executeAllAsync
Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.- Returns:
- Future result of execution for each chunk
-
executeAllAsync
public CompletableFuture<List<TransactionResponse>> executeAllAsync(Client client, Duration timeoutPerChunk) Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.timeoutPerChunk- The timeout after which the execution attempt will be cancelled.- Returns:
- Future result of execution for each chunk
-
executeAllAsync
public void executeAllAsync(Client client, BiConsumer<List<TransactionResponse>, Throwable> callback) Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.callback- a BiConsumer which handles the result or error.
-
executeAllAsync
public void executeAllAsync(Client client, Duration timeout, BiConsumer<List<TransactionResponse>, Throwable> callback) Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.timeout- The timeout after which the execution attempt will be cancelled.callback- a BiConsumer which handles the result or error.
-
executeAllAsync
public void executeAllAsync(Client client, Consumer<List<TransactionResponse>> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.onSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
executeAllAsync
public void executeAllAsync(Client client, Duration timeout, Consumer<List<TransactionResponse>> onSuccess, Consumer<Throwable> onFailure) Execute this transaction or query asynchronously.- Parameters:
client- The client with which this will be executed.timeout- The timeout after which the execution attempt will be cancelled.onSuccess- a Consumer which consumes the result on success.onFailure- a Consumer which consumes the error on failure.
-
executeAsync
Description copied from class:ExecutableExecute this transaction or query asynchronously.Note: This method requires API level 33 or higher. It will not work on devices running API versions below 31 because it uses features introduced in API level 31 (Android 12).
*- Overrides:
executeAsyncin classExecutable<T extends ChunkedTransaction<T>,Transaction, TransactionResponse, TransactionResponse> - Parameters:
client- The client with which this will be executed.timeoutPerChunk- The timeout after which the execution attempt will be cancelled.- Returns:
- Future result of execution
-
schedule
Description copied from class:TransactionExtract the scheduled transaction.- Overrides:
schedulein classTransaction<T extends ChunkedTransaction<T>>- Returns:
- the scheduled transaction
-
getRequiredChunks
int getRequiredChunks()Description copied from class:TransactionThere must be at least one chunk.- Overrides:
getRequiredChunksin classTransaction<T extends ChunkedTransaction<T>>- Returns:
- there is 1 required chunk
-
wipeTransactionLists
void wipeTransactionLists(int requiredChunks) Description copied from class:TransactionWipe / reset the transaction list.- Overrides:
wipeTransactionListsin classTransaction<T extends ChunkedTransaction<T>>- Parameters:
requiredChunks- the number of required chunks
-
onFreezeChunk
abstract void onFreezeChunk(TransactionBody.Builder body, @Nullable TransactionID initialTransactionId, int startIndex, int endIndex, int chunk, int total) A common base for file and topic message transactions. -
shouldGetReceipt
boolean shouldGetReceipt()Should the receipt be retrieved?- Returns:
- by default do not get a receipt
-
bodySizeAllChunks
Get the body sizes for all chunks in a FileAppendTransaction. For transactions with multiple chunks (like large file appends), this returns an array containing the size of each chunk's transaction body. The size is calculated by encoding the transaction body to protobuf format.- Returns:
- List of integers that represent the size of each chunk
-