Example #1
0
        static (bool ok, ReadOnlySequence <byte> ros) FetchBlockByHeightAndHash(int height, KzUInt256?hash, KzBlock b)
        {
            var kzrpc = KzH.GetKzRpc();

            if (hash == null)
            {
                hash = new KzUInt256(kzrpc.GetBlockHash(height));
            }
            var raw = kzrpc.GetBlockRaw(hash.Value).GetBytes();
            var ros = new ReadOnlySequence <byte>(raw);
            var bh  = new KzBlockHeader {
                Height = height
            };

            b.Height = height;
            var tros = ros;

            if (!b.TryReadBlock(ref tros))
            {
                goto fail;
            }
            return(true, ros);

fail:
            return(false, ros);
        }
Example #2
0
        public static int GetLatestBlockHeight()
        {
            var kzrpc  = KzH.GetKzRpc();
            var bci    = kzrpc.GetBlockchainInfo();
            var height = (int)bci.blocks;

            return(height);
        }