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}"); }
public ulong TotalSupply() { return(_totalSupply.GetValue()); }