public void AddTransactionalBlock(IKey key, ulong syncBlockHeight, ushort blockType, ulong blockHeight, byte[] blockContent) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (blockContent == null) { throw new ArgumentNullException(nameof(blockContent)); } TransactionalIdentity transactionalIdentity = GetTransactionalIdentity(key); if (transactionalIdentity == null) { AccountIdentity accountIdentity = GetOrAddIdentity(key); transactionalIdentity = AddTransactionalIdentity(accountIdentity); } BlockHashKey blockHashKey = new BlockHashKey { SyncBlockHeight = syncBlockHeight, Hash = _defaultHashCalculation.CalculateHash(blockContent) }; TransactionalBlock transactionalBlock = new TransactionalBlock() { Identity = transactionalIdentity, HashKey = blockHashKey, SyncBlockHeight = syncBlockHeight, BlockContent = blockContent, BlockHeight = blockHeight, BlockType = blockType }; lock (_sync) { _dataContext.BlockHashKeys.Add(blockHashKey); _dataContext.TransactionalBlocks.Add(transactionalBlock); } }
public bool AddUtxoConfidentialBlock(IKey keyImage, ulong syncBlockHeight, ushort blockType, byte[] destinationKey, byte[] blockContent) { if (_keyImages.Contains(keyImage)) { return(false); } _keyImages.Add(keyImage); lock (_sync) { UtxoConfidentialKeyImage utxoConfidentialKeyImage = new UtxoConfidentialKeyImage { KeyImage = keyImage.Value.ToArray() }; BlockHashKey blockHashKey = new BlockHashKey { SyncBlockHeight = syncBlockHeight, Hash = _defaultHashCalculation.CalculateHash(blockContent) }; UtxoConfidentialBlock utxoConfidentialBlock = new UtxoConfidentialBlock { KeyImage = utxoConfidentialKeyImage, HashKey = blockHashKey, SyncBlockHeight = syncBlockHeight, BlockType = blockType, DestinationKey = destinationKey, BlockContent = blockContent }; _dataContext.UtxoConfidentialKeyImages.Add(utxoConfidentialKeyImage); _dataContext.BlockHashKeys.Add(blockHashKey); _dataContext.UtxoConfidentialBlocks.Add(utxoConfidentialBlock); } return(true); }