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); }
private string WriteHeader(string stateRoot, DataHeader header) { fdb.Write($"root/{stateRoot}", header); return(stateRoot); }