コード例 #1
0
ファイル: ChainState.cs プロジェクト: pjc0247/minichain
        internal bool PushBlock(Block block)
        {
            if (block == null)
            {
                throw new ArgumentNullException(nameof(block));
            }
            if (currentBlock == null)
            {
                currentBlock = block;
            }

            try
            {
                lock (blockLock)
                {
                    // In case that new block is came from another branch:
                    if (currentBlock != null &&
                        block.prevBlockHash != currentBlock.hash)
                    {
                        ;
                    }

                    fdb.Write($"block/{block.hash}", block);

                    ApplyTransactions(block);

                    // CONFIRMED
                    currentBlock = block;

                    onBlockConfirmed?.Invoke(block);

                    return(true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(false);
        }
コード例 #2
0
 private string WriteHeader(string stateRoot, DataHeader header)
 {
     fdb.Write($"root/{stateRoot}", header);
     return(stateRoot);
 }