示例#1
0
        public void WriteParentChainBlockInfo(ParentChainBlockInfo parentChainBlockInfo)
        {
            ulong parentChainHeight = parentChainBlockInfo.Height;
            var   currentHeight     = _currentParentChainHeight.GetValue();
            var   target            = currentHeight != 0 ? currentHeight + 1: GlobalConfig.GenesisBlockHeight;

            Api.Assert(target == parentChainHeight,
                       $"Parent chain block info at height {target} is needed, not {parentChainHeight}");
            Console.WriteLine("ParentChainBlockInfo.Height is correct.");

            var key = new UInt64Value {
                Value = parentChainHeight
            };

            Api.Assert(_parentChainBlockInfo.GetValue(key) == null,
                       $"Already written parent chain block info at height {parentChainHeight}");
            Console.WriteLine("Writing ParentChainBlockInfo..");
            foreach (var _ in parentChainBlockInfo.IndexedBlockInfo)
            {
                BindParentChainHeight(_.Key, parentChainHeight);
                AddIndexedTxRootMerklePathInParentChain(_.Key, _.Value);
            }
            _parentChainBlockInfo.SetValueAsync(key, parentChainBlockInfo).Wait();
            _currentParentChainHeight.SetValue(parentChainHeight);

            // only for debug
            Console.WriteLine($"WriteParentChainBlockInfo success at {parentChainHeight}");
        }
示例#2
0
 public ulong TotalSupply()
 {
     return(_totalSupply.GetValue());
 }