Пример #1
0
        private ContractState GetHistoricalContractState(Trie trie, UInt160 script_hash)
        {
            const byte prefix = 8;
            StorageKey skey   = new KeyBuilder(NativeContract.ContractManagement.Id, prefix).Add(script_hash);

            return(trie.TryGetValue(skey.ToArray(), out var value) ? value.AsSerializable <StorageItem>().GetInteroperable <ContractState>() : null);
        }
Пример #2
0
        public void Test()
        {
            var key = new KeyBuilder(1, 2);

            Assert.AreEqual("0100000002", key.ToArray().ToHexString());

            key = new KeyBuilder(1, 2);
            key = key.Add(new byte[] { 3, 4 });
            Assert.AreEqual("01000000020304", key.ToArray().ToHexString());

            key = new KeyBuilder(1, 2);
            key = key.Add(new byte[] { 3, 4 });
            key = key.Add(UInt160.Zero);
            Assert.AreEqual("010000000203040000000000000000000000000000000000000000", key.ToArray().ToHexString());

            key = new KeyBuilder(1, 2);
            key = key.Add(new a()
            {
                x = 123
            });
            Assert.AreEqual("01000000027b000000", key.ToArray().ToHexString());

            key = new KeyBuilder(1, 0);
            key = key.AddBigEndian(new a()
            {
                x = 1
            });
            Assert.AreEqual("010000000000000001", key.ToArray().ToHexString());
        }