All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.hyperchain.sdk.service.TxService Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package cn.hyperchain.sdk.service;

import cn.hyperchain.sdk.exception.RequestException;
import cn.hyperchain.sdk.request.Request;
import cn.hyperchain.sdk.response.ReceiptListResponse;
import cn.hyperchain.sdk.response.ReceiptResponse;
import cn.hyperchain.sdk.response.TxHashResponse;
import cn.hyperchain.sdk.response.TxHashesResponse;
import cn.hyperchain.sdk.response.tx.TxAvgTimeResponse;
import cn.hyperchain.sdk.response.tx.TxCountResponse;
import cn.hyperchain.sdk.response.tx.TxCountWithTSResponse;
import cn.hyperchain.sdk.response.tx.TxLimitResponse;
import cn.hyperchain.sdk.response.tx.TxResponse;
import cn.hyperchain.sdk.response.tx.TxVersionResponse;

import cn.hyperchain.sdk.service.params.FilterParam;
import cn.hyperchain.sdk.service.params.MetaDataParam;
import cn.hyperchain.sdk.transaction.Transaction;

import java.math.BigInteger;
import java.util.ArrayList;

/**
 * Tx service interface.
 *
 * @author dong
 * @date 07/02/2019
 */
public interface TxService {

    /**
     * @see TxService#getTx(String, String, int...)
     */
    @Deprecated
    Request getTx(BigInteger from, BigInteger to, int... nodeIds);

    /**
     * get transactions by a given block number range.
     *
     * @param from    from block number
     * @param to      to block number
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getTx(String from, String to, int... nodeIds);


    /**
     * @see TxService#getTxsWithLimit(String, String, MetaDataParam, int...)
     */
    Request getTxsWithLimit(String from, String to, int... nodeIds);

    /**
     * get transactions by a given block number range with limit.
     *
     * @param from     from block number
     * @param to       to block number
     * @param metaData meta data
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getTxsWithLimit(String from, String to, MetaDataParam metaData, int... nodeIds);


    /**
     * get invalid transactions by a given block number range with limit.
     *
     * @param from     from block number
     * @param to       to block number
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getInvalidTxsWithLimit(Integer from, Integer to, int... nodeIds);

    /**
     * @see TxService#getInvalidTxsWithLimit(String, String, int...)
     */
    Request getInvalidTxsWithLimit(String from, String to, int... nodeIds);

    /**
     * get invalid transactions by a given block number range with limit.
     *
     * @param from     from block number
     * @param to       to block number
     * @param metaData meta data
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getInvalidTxsWithLimit(String from, String to, MetaDataParam metaData, int... nodeIds);

    /**
     * get all discard transactions.
     *
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getDiscardTx(int... nodeIds);


    /**
     * @see TxService#getTxByHash(String, boolean, int...)
     */
    Request getTxByHash(String txHash, int... nodeIds);

    /**
     * get transaction details by querying transaction hash.
     *
     * @param txHash      transaction hash
     * @param isPrivateTx is this a private transaction (default false)
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getTxByHash(String txHash, boolean isPrivateTx, int... nodeIds);

    /**
     * get transaction details by querying block hash and index.
     *
     * @param blockHash block hash
     * @param idx       The position of the transaction in the block
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getTxByBlockHashAndIndex(String blockHash, int idx, int... nodeIds);

    /**
     * get transaction details by querying block number and index.
     *
     * @param blockNumber block number
     * @param idx         The position of the transaction in the block
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getTxByBlockNumAndIndex(int blockNumber, int idx, int... nodeIds);

    /**
     * @see TxService#getTxByBlockNumAndIndex(int, int, int...)
     */
    Request getTxByBlockNumAndIndex(String blockNumber, String idx, int... nodeIds);

    /**
     * get average deal time of blocks with a given range.
     *
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxAvgTimeResponse}
     */
    Request getTxAvgTimeByBlockNumber(BigInteger from, BigInteger to, int... nodeIds);

    /**
     * @see TxService#getTxAvgTimeByBlockNumber(BigInteger, BigInteger, int...)
     */
    Request getTxAvgTimeByBlockNumber(String from, String to, int... nodeIds);

    /**
     * query all transactions on the chain.
     *
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxCountWithTSResponse}
     */
    Request getTransactionsCount(int... nodeIds);

    /**
     * query all invalid transactions on the chain.
     *
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxCountWithTSResponse}
     */
    Request getInvalidTransactionsCount(int... nodeIds);

    /**
     * get receipt information of the transaction by querying transaction hash.
     *
     * @param txHash  transaction hash
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getTransactionReceipt(String txHash, int... nodeIds);

    /**
     * get receipt information of the transaction by querying transaction hash after seqNo has been confirmed.
     *
     * @param txHash  transaction hash
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getConfirmedTransactionReceipt(String txHash, int... nodeIds);

    /**
     * get receipt information of the transaction by querying transaction hash.
     *
     * @param txHash  transaction hash
     * @param nodeIds specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getTransactionReceiptWithGas(String txHash, int... nodeIds);

    /**
     * query the count of transactions in the block with a given block hash.
     *
     * @param blockHash block hash
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxCountResponse}
     */
    Request getBlockTxCountByHash(String blockHash, int... nodeIds);

    /**
     * query the count of transactions in the block with a given block number.
     *
     * @param blockNumber block number
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxCountResponse}
     */
    Request getBlockTxCountByNumber(String blockNumber, int... nodeIds);

    /**
     * query the invalid transactions in the block with a given block hash.
     *
     * @param blockHash block hash
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getInvalidTxsByBlockHash(String blockHash, int... nodeIds);

    /**
     * query the invalid transactions in the block with a given block number.
     *
     * @param blockNumber block number
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getInvalidTxsByBlockNumber(BigInteger blockNumber, int... nodeIds);

    /**
     * query the invalid transactions in the block with a given block number.
     *
     * @param blockNumber block number
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getInvalidTxsByBlockNumber(String blockNumber, int... nodeIds);

    /**
     * get signature hash for the transaction.
     *
     * @param from      initiator address
     * @param nonce     16-bit random number
     * @param extra     extra information
     * @param payload   bytecode for the contract
     * @param timestamp timestamp of the transaction
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getSignHash(String from, BigInteger nonce, String extra, String payload, BigInteger timestamp, int... nodeIds);

    /**
     * @see TxService#getSignHash(String, BigInteger, String, String, BigInteger, int...)
     */
    Request getSignHash(String from, BigInteger nonce, String payload, BigInteger timestamp, int... nodeIds);

    /**
     * get signature hash for the transaction (without contract).
     *
     * @param from      initiator address
     * @param to        receiver address
     * @param nonce     16-bit random number
     * @param extra     extra information
     * @param value     transaction amount
     * @param timestamp timestamp of the transaction
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getSignHash(String from, String to, BigInteger nonce, String extra, String value, BigInteger timestamp, int... nodeIds);

    /**
     * @see TxService#getSignHash(String, String, BigInteger, String, String, BigInteger, int...)
     */
    Request getSignHash(String from, String to, BigInteger nonce, String value, BigInteger timestamp, int... nodeIds);

    /**
     * querying transactions within a specified time interval.
     *
     * @param startTime start time
     * @param endTime   end time
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getTransactionsByTime(BigInteger startTime, BigInteger endTime, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTime(String, String, int...)
     */
    @Deprecated
    Request getTransactionsByTime(String startTime, String endTime, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTimeWithLimit(BigInteger, BigInteger, MetaDataParam, FilterParam, int...)
     */
    Request getTransactionsByTimeWithLimit(String startTime, String endTime, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTimeWithLimit(BigInteger, BigInteger, MetaDataParam, FilterParam, int...)
     */
    Request getTransactionsByTimeWithLimit(BigInteger startTime, BigInteger endTime, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTimeWithLimit(BigInteger, BigInteger, MetaDataParam, FilterParam, int...)
     */
    Request getTransactionsByTimeWithLimit(String startTime, String endTime, MetaDataParam metaData, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTimeWithLimit(BigInteger, BigInteger, MetaDataParam, FilterParam, int...)
     */
    Request getTransactionsByTimeWithLimit(String startTime, String endTime, MetaDataParam metaData, FilterParam filter, int... nodeIds);

    /**
     * @see TxService#getTransactionsByTimeWithLimit(BigInteger, BigInteger, MetaDataParam, FilterParam, int...)
     */
    Request getTransactionsByTimeWithLimit(BigInteger startTime, BigInteger endTime, MetaDataParam metaData, int... nodeIds);

    /**
     * querying transactions within a specified time interval with limit.
     *
     * @param startTime start time
     * @param endTime   end time
     * @param metaData  meta data
     * @param filter    filter items
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getTransactionsByTimeWithLimit(BigInteger startTime, BigInteger endTime, MetaDataParam metaData, FilterParam filter, int... nodeIds);

    /**
     * get discard transactions by time.
     *
     * @param startTime start time
     * @param endTime   end time
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getDiscardTransactionsByTime(BigInteger startTime, BigInteger endTime, int... nodeIds);

    /**
     * @see TxService#getDiscardTransactionsByTime(BigInteger, BigInteger, int...)
     */
    @Deprecated
    Request getDiscardTransactionsByTime(String startTime, String endTime, int... nodeIds);

    /**
     * get transaction count by contract address.
     *
     * @param from            start block number
     * @param to              end block number
     * @param contractAddress contract address
     * @param txExtra         if contains extra
     * @param nodeIds         specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getTransactionsCountByContractAddr(String from, String to, String contractAddress, boolean txExtra, int... nodeIds);

    /**
     * @see TxService#getTransactionsCountByContractAddr(String, String, String, boolean, int...)
     */
    @Deprecated
    Request getTransactionsCountByContractAddr(BigInteger from, BigInteger to, String contractAddress, boolean txExtra, int... nodeIds);

    /**
     * get next page transactions.
     *
     * @param blkNumber      block number
     * @param txIndex        transaction index in the block
     * @param minBlkNumber   minimum block number
     * @param maxBlkNumber   maximum block number
     * @param separated      the number of transactions to skip
     * @param pageSize       the number of transactions to return
     * @param containCurrent true ndicates that the returned result includes the transaction with the position txIndex in the blkNumber block. If the transaction is not a transaction with the contract address of the address contract, it is not counted
     * @param address        contract address
     * @param nodeIds        specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getNextPageTransactions(BigInteger blkNumber, BigInteger txIndex, BigInteger minBlkNumber, BigInteger maxBlkNumber, BigInteger separated, BigInteger pageSize, boolean containCurrent, String address, int... nodeIds);

    /**
     * @see TxService#getNextPageTransactions(BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, boolean, String, int...)
     */
    @Deprecated
    Request getNextPageTransactions(String blkNumber, String txIndex, String minBlkNumber, String maxBlkNumber, String separated, String pageSize, boolean containCurrent, String address, int... nodeIds);

    /**
     * get next page invalid transactions.
     *
     * @param blkNumber      block number
     * @param txIndex        transaction index in the block
     * @param minBlkNumber   minimum block number
     * @param maxBlkNumber   maximum block number
     * @param separated      the number of transactions to skip
     * @param pageSize       the number of transactions to return
     * @param containCurrent true ndicates that the returned result includes the transaction with the position txIndex in the blkNumber block. If the transaction is not a transaction with the contract address of the address contract, it is not counted
     * @param nodeIds        specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getNextPageInvalidTransactions(BigInteger blkNumber, BigInteger txIndex, BigInteger minBlkNumber, BigInteger maxBlkNumber, BigInteger separated, BigInteger pageSize, boolean containCurrent, int... nodeIds);

    /**
     * @see TxService#getNextPageTransactions(BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, BigInteger, boolean, String, int...)
     */
    Request getNextPageInvalidTransactions(String blkNumber, String txIndex, String minBlkNumber, String maxBlkNumber, String separated, String pageSize, boolean containCurrent, int... nodeIds);


    /**
     * get previous page transactions.
     *
     * @param blkNumber      block number
     * @param txIndex        transaction index in the block
     * @param minBlkNumber   minimum block number
     * @param maxBlkNumber   maximum block number
     * @param separated      the number of transactions to skip
     * @param pageSize       the number of transactions to return
     * @param containCurrent true ndicates that the returned result includes the transaction with the position txIndex in the blkNumber block. If the transaction is not a transaction with the contract address of the address contract, it is not counted
     * @param address        contract address
     * @param nodeIds        specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getPrevPageTransactions(BigInteger blkNumber, BigInteger txIndex, BigInteger minBlkNumber, BigInteger maxBlkNumber, BigInteger separated, BigInteger pageSize, boolean containCurrent, String address, int... nodeIds);

    /**
     * @see TxService#getPrevPageTransactions(String, String, String, String, String, String, boolean, String, int...)
     */
    @Deprecated
    Request getPrevPageTransactions(String blkNumber, String txIndex, String minBlkNumber, String maxBlkNumber, String separated, String pageSize, boolean containCurrent, String address, int... nodeIds);

    /**
     * get previous page transactions.
     *
     * @param blkNumber      block number
     * @param txIndex        transaction index in the block
     * @param minBlkNumber   minimum block number
     * @param maxBlkNumber   maximum block number
     * @param separated      the number of transactions to skip
     * @param pageSize       the number of transactions to return
     * @param containCurrent true ndicates that the returned result includes the transaction with the position txIndex in the blkNumber block. If the transaction is not a transaction with the contract address of the address contract, it is not counted
     * @param nodeIds        specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    Request getPrevPageInvalidTransactions(BigInteger blkNumber, BigInteger txIndex, BigInteger minBlkNumber, BigInteger maxBlkNumber, BigInteger separated, BigInteger pageSize, boolean containCurrent, int... nodeIds);

    /**
     * @see TxService#getPrevPageTransactions(String, String, String, String, String, String, boolean, String, int...)
     */
    Request getPrevPageInvalidTransactions(String blkNumber, String txIndex, String minBlkNumber, String maxBlkNumber, String separated, String pageSize, boolean containCurrent, int... nodeIds);


    /**
     * Get batch transactions.
     *
     * @param txHashList transaction hash list
     * @param nodeIds    specific ids
     * @return {@link Request} of {@link TxResponse}
     */
    @Deprecated
    Request getBatchTxByHash(ArrayList txHashList, int... nodeIds);

    @Deprecated
    Request getBatchReceipt(ArrayList txHashList, int... nodeIds);

    /**
     * query the count of transactions with a given period.
     *
     * @param startTime start time
     * @param endTime   end time
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxCountResponse}
     */
    @Deprecated
    Request getTxsCountByTime(BigInteger startTime, BigInteger endTime, int... nodeIds);

    /**
     * query the count of invalid transactions with a given period.
     *
     * @param startTime start time
     * @param endTime   end time
     * @param nodeIds   specific ids
     * @return {@link Request} of {@link TxCountResponse}
     */
    Request getInvalidTxsCountByTime(BigInteger startTime, BigInteger endTime, int... nodeIds);

    /**
     * get transactions by extraID.
     *
     * @param mode     query type for extraID
     * @param detail   detail transactions info
     * @param metaData meta data
     * @param filter   filter
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getTxsByExtraID(int mode, boolean detail, MetaDataParam metaData, FilterParam filter, int... nodeIds);

    /**
     * get transactions by filter.
     *
     * @param mode     query type for filter
     * @param detail   detail transactions info
     * @param metaData meta data
     * @param filter   filter
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link TxLimitResponse}
     */
    Request getTxsByFilter(int mode, boolean detail, MetaDataParam metaData, FilterParam filter, int... nodeIds);

    /**
     * send tx.
     *
     * @param transaction transaction to be send
     * @param nodeIds     specific ids
     * @return {@link Request} of {@link TxHashesResponse}
     */
    Request sendTx(Transaction transaction, int... nodeIds);


    /**
     *
     * @param transaction transaction to be send.
     * @param nodeIds  specific ids
     * @return {@link Request} of {@link ReceiptResponse}
     */
    Request grpcSendTxReturnReceipt(Transaction transaction, int... nodeIds);

    /**
     * send batch txs.
     *
     * @param transactions transactions to be send
     * @param methods      methods
     * @param nodeIds      specific ids
     * @return {@link Request} of {@link TxHashesResponse}
     */
    Request sendBatchTxs(ArrayList transactions, ArrayList methods, int... nodeIds);

    /**
     * get TxVersion.
     *
     * @return String
     */
    Request getTxVersion(int nodeId) throws RequestException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy