Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.hedera.hashgraph.sdk;
import com.google.errorprone.annotations.Var;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.hedera.hashgraph.sdk.proto.SignatureMap;
import com.hedera.hashgraph.sdk.proto.SignedTransaction;
import com.hedera.hashgraph.sdk.proto.TransactionBody;
import com.hedera.hashgraph.sdk.proto.TransactionID;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.annotation.Nullable;
/**
* A common base for file and topic message transactions.
*/
abstract class ChunkedTransaction> extends Transaction {
private int chunkSize = 1024;
/**
* The transaction data
*/
protected ByteString data = ByteString.EMPTY;
/**
* Maximum number of chunks this message will get broken up into when
* it's frozen.
*/
private int maxChunks = 20;
/**
* Constructor.
*
* @param txs Compound list of transaction id's list of (AccountId, Transaction) records
* @throws InvalidProtocolBufferException when there is an issue with the protobuf
*/
ChunkedTransaction(LinkedHashMap> txs) throws InvalidProtocolBufferException {
super(txs);
}
/**
* Constructor.
*
* @param txBody protobuf TransactionBody
*/
ChunkedTransaction(com.hedera.hashgraph.sdk.proto.TransactionBody txBody) {
super(txBody);
}
/**
* Constructor.
*/
ChunkedTransaction() {
super();
}
/**
* Extract the data.
*
* @return the data
*/
ByteString getData() {
return data;
}
/**
* Assign the data via a byte array.
*
* @param data the byte array
* @return {@code this}
*/
T setData(byte[] data) {
requireNotFrozen();
this.data = ByteString.copyFrom(data);
// noinspection unchecked
return (T) this;
}
/**
* Assign the data via a byte string.
*
* @param data the byte string
* @return {@code this}
*/
T setData(ByteString data) {
requireNotFrozen();
this.data = data;
// noinspection unchecked
return (T) this;
}
/**
* Assign the data via a string.
*
* @param text the byte array
* @return {@code this}
*/
T setData(String text) {
requireNotFrozen();
this.data = ByteString.copyFromUtf8(text);
// noinspection unchecked
return (T) this;
}
/**
* Retrieve the maximum number of chunks.
*
* @return the number of chunks
*/
public int getMaxChunks() {
return maxChunks;
}
/**
* Assign the max number of chunks.
*
* @param maxChunks the number of chunks
* @return {@code this}
*/
public T setMaxChunks(int maxChunks) {
requireNotFrozen();
this.maxChunks = maxChunks;
// noinspection unchecked
return (T) this;
}
/**
* Retrieve the chunk size.
*
* @return the chunk size
*/
public int getChunkSize() {
return chunkSize;
}
/**
* Assign the chunk size.
*
* @param chunkSize the chunk size
* @return {@code this}
*/
public T setChunkSize(int chunkSize) {
requireNotFrozen();
this.chunkSize = chunkSize;
// noinspection unchecked
return (T) this;
}
@Override
public byte[] getTransactionHash() {
if (outerTransactions.size() > nodeAccountIds.size()) {
throw new IllegalStateException("a single transaction hash can not be calculated for a chunked transaction, try calling `getAllTransactionHashesPerNode`");
}
return super.getTransactionHash();
}
@Override
public Map getTransactionHashPerNode() {
if (outerTransactions.size() > nodeAccountIds.size()) {
throw new IllegalStateException("a single transaction hash can not be calculated for a chunked transaction, try calling `getAllTransactionHashesPerNode`");
}
return super.getTransactionHashPerNode();
}
/**
* Extract the list of transaction hashes.
*
* @return the list of transaction hashes
*/
public final List