Пример #1
0
        /// <summary>
        /// Retrieves a transaction block given a valid hash.
        /// This function is used by other methods in this class and not explicitly by RPC/API.
        /// </summary>
        /// <param name="trxid">A valid uint256 hash</param>
        /// <param name="fullNode">The full node. Used to access <see cref="IBlockStore"/>.</param>
        /// <param name="chain">The full node's chain. Used to get <see cref="ChainedHeader"/> block.</param>
        /// <returns>A <see cref="ChainedHeader"/> for the given transaction hash. Returns <c>null</c> if fails.</returns>
        /// <exception cref="ArgumentNullException">Thrown if fullnode is not provided.</exception>
        internal ChainedHeader GetTransactionBlock(uint256 trxid, IFullNode fullNode, ChainIndexer chain)
        {
            Guard.NotNull(fullNode, nameof(fullNode));

            ChainedHeader block      = null;
            var           blockStore = fullNode.NodeFeature <IBlockStore>();
            uint256       blockid    = blockStore?.GetBlockIdByTransactionId(trxid);

            if (blockid != null)
            {
                block = chain?.GetHeader(blockid);
            }

            return(block);
        }
Пример #2
0
        public MiningController(IConsensusManager consensusManager, IFullNode fullNode, ILoggerFactory loggerFactory, Network network, IPowMining powMining, IWalletManager walletManager)
        {
            Guard.NotNull(consensusManager, nameof(consensusManager));
            Guard.NotNull(fullNode, nameof(fullNode));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(powMining, nameof(powMining));
            Guard.NotNull(walletManager, nameof(walletManager));

            this.consensusManager = consensusManager;
            this.logger           = loggerFactory.CreateLogger("Impleum.Bitcoin.Fullnode");
            this.miningFeature    = fullNode.NodeFeature <MiningFeature>();
            this.network          = network;
            this.powMining        = powMining;
            this.walletManager    = walletManager;
        }
        /// <summary>
        /// Retrieves a transaction block given a valid hash.
        /// This function is used by other methods in this class and not explicitly by RPC/API.
        /// </summary>
        /// <param name="trxid">A valid uint256 hash</param>
        /// <param name="fullNode">The full node. Used to access <see cref="IBlockStore"/>.</param>
        /// <param name="chain">The full node's chain. Used to get <see cref="ChainedHeader"/> block.</param>
        /// <returns>A <see cref="ChainedHeader"/> for the given transaction hash. Returns <c>null</c> if fails.</returns>
        /// <exception cref="ArgumentNullException">Thrown if fullnode is not provided.</exception>
        internal static async Task <ChainedHeader> GetTransactionBlockAsync(uint256 trxid,
                                                                            IFullNode fullNode, ChainBase chain)
        {
            Guard.NotNull(fullNode, nameof(fullNode));

            ChainedHeader block      = null;
            var           blockStore = fullNode.NodeFeature <IBlockStore>();
            uint256       blockid    = blockStore != null ? await blockStore.GetBlockIdByTransactionIdAsync(trxid).ConfigureAwait(false) : null;

            if (blockid != null)
            {
                block = chain?.GetBlock(blockid);
            }

            return(block);
        }