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

cc.youchain.protocol.rx.YOUChainRx Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package cc.youchain.protocol.rx;

import java.util.List;

import cc.youchain.protocol.core.DefaultBlockParameter;
import cc.youchain.protocol.core.methods.request.YOUFilter;
import cc.youchain.protocol.core.methods.response.YOUBlock;
import cc.youchain.protocol.core.methods.response.Log;
import cc.youchain.protocol.core.methods.response.Transaction;
import cc.youchain.protocol.websocket.events.LogNotification;
import cc.youchain.protocol.websocket.events.NewHeadsNotification;
import cc.youchain.protocol.websocket.events.PendingTransactionNotification;
import cc.youchain.protocol.websocket.events.SyncingNotfication;
import io.reactivex.Flowable;

/**
 * The Flowables JSON-RPC client event API.
 */
public interface YOUChainRx {

    /**
     * Create an flowable to filter for specific log events on the blockchain.
     *
     * @param youFilter filter criteria
     * @return a {@link Flowable} instance that emits all Log events matching the filter
     */
    Flowable youLogFlowable(YOUFilter youFilter);

    /**
     * Create an Flowable to emit block hashes.
     *
     * @return a {@link Flowable} instance that emits all new block hashes as new blocks are
     * created on the blockchain
     */
    Flowable youBlockHashFlowable();

    /**
     * Create an Flowable to emit pending transactions, i.e. those transactions that have been
     * submitted by a node, but don't yet form part of a block (haven't been mined yet).
     *
     * @return a {@link Flowable} instance to emit pending transaction hashes.
     */
    Flowable youPendingTransactionHashFlowable();

    /**
     * Create an {@link Flowable} instance to emit all new transactions as they are confirmed on
     * the blockchain. i.e. they have been mined and are incorporated into a block.
     *
     * @return a {@link Flowable} instance to emit new transactions on the blockchain
     */
    Flowable transactionFlowable();

    /**
     * Create an {@link Flowable} instance to emit all pending transactions that have yet to be
     * placed into a block on the blockchain.
     *
     * @return a {@link Flowable} instance to emit pending transactions
     */
    Flowable pendingTransactionFlowable();

    /**
     * Create an {@link Flowable} instance that emits newly created blocks on the blockchain.
     *
     * @param fullTransactionObjects if true, provides transactions embedded in blocks, otherwise
     *                               transaction hashes
     * @return a {@link Flowable} instance that emits all new blocks as they are added to the
     * blockchain
     */
    Flowable blockFlowable(boolean fullTransactionObjects);

    /**
     * Create an {@link Flowable} instance that emits all blocks from the blockchain contained
     * within the requested range.
     *
     * @param startBlock             block number to commence with
     * @param endBlock               block number to finish with
     * @param fullTransactionObjects if true, provides transactions embedded in blocks, otherwise
     *                               transaction hashes
     * @return a {@link Flowable} instance to emit these blocks
     */
    Flowable replayPastBlocksFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock,
            boolean fullTransactionObjects);

    /**
     * Create an {@link Flowable} instance that emits all blocks from the blockchain contained
     * within the requested range.
     *
     * @param startBlock             block number to commence with
     * @param endBlock               block number to finish with
     * @param fullTransactionObjects if true, provides transactions embedded in blocks, otherwise
     *                               transaction hashes
     * @param ascending              if true, emits blocks in ascending order between range, otherwise
     *                               in descending order
     * @return a {@link Flowable} instance to emit these blocks
     */
    Flowable replayPastBlocksFlowable(
            DefaultBlockParameter startBlock, DefaultBlockParameter endBlock,
            boolean fullTransactionObjects, boolean ascending);

    /**
     * Create a {@link Flowable} instance that emits all transactions from the blockchain
     * starting with a provided block number. Once it has replayed up to the most current block,
     * the provided Flowable is invoked.
     *
     * 

To automatically subscribe to new blocks, use * {@link #replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean)}. * * @param startBlock the block number we wish to request from * @param fullTransactionObjects if we require full {@link Transaction} objects to be provided * in the {@link YOUBlock} responses * @param onCompleteFlowable a subsequent Flowable that we wish to run once we are caught * up with the latest block * @return a {@link Flowable} instance to emit all requested blocks */ Flowable replayPastBlocksFlowable( DefaultBlockParameter startBlock, boolean fullTransactionObjects, Flowable onCompleteFlowable); /** * Creates a {@link Flowable} instance that emits all blocks from the requested block number * to the most current. Once it has emitted the most current block, onComplete is called. * * @param startBlock the block number we wish to request from * @param fullTransactionObjects if we require full {@link Transaction} objects to be provided * in the {@link YOUBlock} responses * @return a {@link Flowable} instance to emit all requested blocks */ Flowable replayPastBlocksFlowable( DefaultBlockParameter startBlock, boolean fullTransactionObjects); /** * Create a {@link Flowable} instance that emits all transactions from the blockchain * contained within the requested range. * * @param startBlock block number to commence with * @param endBlock block number to finish with * @return a {@link Flowable} instance to emit these transactions in the order they * appear in the blocks */ Flowable replayPastTransactionsFlowable( DefaultBlockParameter startBlock, DefaultBlockParameter endBlock); /** * Creates a {@link Flowable} instance that emits all transactions from the requested block * number to the most current. Once it has emitted the most current block's transactions, * onComplete is called. * * @param startBlock the block number we wish to request from * @return a {@link Flowable} instance to emit all requested transactions */ Flowable replayPastTransactionsFlowable( DefaultBlockParameter startBlock); /** * Creates a {@link Flowable} instance that emits all blocks from the requested block number * to the most current. Once it has emitted the most current block, it starts emitting new * blocks as they are created. * * @param startBlock the block number we wish to request from * @param fullTransactionObjects if we require full {@link Transaction} objects to be provided * in the {@link YOUBlock} responses * @return a {@link Flowable} instance to emit all requested blocks and future */ Flowable replayPastAndFutureBlocksFlowable( DefaultBlockParameter startBlock, boolean fullTransactionObjects); /** * As per * {@link #replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean)}, * except that all transactions contained within the blocks are emitted. * * @param startBlock the block number we wish to request from * @return a {@link Flowable} instance to emit all requested transactions and future */ Flowable replayPastAndFutureTransactionsFlowable( DefaultBlockParameter startBlock); /** * Creates a {@link Flowable} instance that emits a notification when a new header is appended * to a chain, including chain reorganizations. * * @return a {@link Flowable} instance that emits a notification for every new header */ Flowable newHeadsNotifications(); /** * Creates an {@link Flowable} instance that emits a notification when a new transaction is * added to the pending state and is signed with a key that is available in the node. * * @return a {@link Flowable} instance that emits a notification when a new transaction is added * to the pending state */ Flowable newPendingTransactionsNotifications(); /** * Creates an {@link Flowable} instance that emits a notification when a node starts or stops * syncing. * * @return a {@link Flowable} instance that emits changes to syncing status */ Flowable syncingStatusNotifications(); /** * Creates aa {@link Flowable} instance that emits notifications for logs included in new * imported blocks. * * @param addresses only return logs from this list of address. Return logs from all addresses * if the list is empty * @param topics only return logs that match specified topics. Returns logs for all topics if * the list is empty * @return a {@link Flowable} instance that emits logs included in new blocks */ Flowable logsNotifications(List addresses, List topics); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy