コード例 #1
0
        IBlockchainCache findAlternativeSegmentContainingBlock(string blockHash)
        {
            IBlockchainCache cache = null;

            /*std::find_if(++chainsLeaves.begin(), chainsLeaves.end(),
             * [&] (IBlockchainCache* chain) { return cache = findIndexInChain(chain, blockHash);
             * });*/
            return(cache);
        }
コード例 #2
0
        public IBlockchainCache findIndexInChain(IBlockchainCache blockSegment, string blockHash)
        {
            if (blockSegment == null)
            {
                throw new Exception();
            }

            while (blockSegment != null)
            {
                if (blockSegment.hasBlock(blockHash))
                {
                    return(blockSegment);
                }
                blockSegment = blockSegment.getParent();
            }
            return(null);
        }
コード例 #3
0
        public IBlockchainCache findSegmentContainingBlock(string blockHash)
        {
            if (Globals.DAEMON_CHAIN_LEAVES.Length < 1)
            {
                throw new Exception("Chain leaves must be greater than 0");
            }

            // first search in main chain
            IBlockchainCache blockSegment = findIndexInChain(Globals.DAEMON_CHAIN_LEAVES[0], blockHash);

            if (blockSegment != null)
            {
                return(blockSegment);
            }

            // than search in alternative chains
            return(findAlternativeSegmentContainingBlock(blockHash));
        }