コード例 #1
0
        public static void GetBestBlockRef()
        {
            var    blockRefByte = BlockClient.GetBlock(Revision.BEST).BlockRef().ToByteArray();
            string blockRef     = ByteUtils.ToHexString(blockRefByte, null);

            WriteLine("BlockRef:");
            WriteLine("0x" + blockRef);
        }
コード例 #2
0
        public void simple_synchronous_call_getblock_height_returns_result_with_proxy()
        {
            BlockClient client = new BlockClient();
            Block       block  = client.GetBlock(Network.Doge, 200000);

            Assert.IsNotNull(block);
            Assert.IsTrue(block.Status == Consts.Success);
            Assert.IsTrue(block.Data.Blockhash == "092fd3e76db5ff35fbfefe48d5c53ca26e799f0654a4036ddd5fd78de77418c2");
            Assert.IsTrue(block.Data.Size == 20686);
        }
コード例 #3
0
        public static void getBestBlock(string[] args)
        {
            Block block = null;

            if (args != null && args.Length > 2)
            {
                var revision = Revision.Create(long.Parse(args[2]));
                block = BlockClient.GetBlock(revision);
            }
            else
            {
                block = BlockClient.GetBlock(Revision.BEST);
            }
            WriteLine("Block:");
            WriteLine(JsonConvert.SerializeObject(block));
        }
コード例 #4
0
        public void should_simple_synchronous_call_getblock_height_with_bad_height_throws_exception()
        {
            BlockClient client = new BlockClient();
            ExceptionWithMessage <BlockError> typedException = null;

            try
            {
                client.GetBlock(Network.Doge, -1);
            }
            catch (Exception e)
            {
                typedException = e?.InnerException as ExceptionWithMessage <BlockError>;
            }
            Assert.IsNotNull(typedException);
            Assert.IsNotNull(typedException.ErrorMessage);
            Assert.IsTrue(typedException.ErrorMessage.Status == Consts.Fail);
        }