/// <summary> /// /// </summary> /// <param name="transactionModel"></param> /// <returns></returns> public VerifyResult Add(byte[] transactionModel) { Guard.Argument(transactionModel, nameof(transactionModel)).NotNull(); try { var transaction = Helper.Util.DeserializeFlatBuffer <TransactionModel>(transactionModel); if (transaction.Validate().Any()) { return(VerifyResult.Invalid); } if (!_pooledSeenTransactions.Contains(transaction.TxnId.ByteToHex())) { _pooledSeenTransactions.Add(transaction.TxnId.ByteToHex()); _pooledTransactions.Add(transaction); _localNode.Broadcast(TopicType.AddTransaction, transactionModel); } } catch (Exception ex) { _logger.Here().Error(ex, ex.Message); return(VerifyResult.Invalid); } return(VerifyResult.Succeed); }
/// <summary> /// /// </summary> /// <param name="blockGraph"></param> /// <returns></returns> private async Task Publish(BlockGraph blockGraph) { Guard.Argument(blockGraph, nameof(blockGraph)).NotNull(); try { var peers = await _localNode.GetPeers(); await _localNode.Broadcast(peers.Values.ToArray(), TopicType.AddBlockGraph, Helper.Util.SerializeFlatBuffer(blockGraph)); } catch (Exception ex) { _logger.Here().Error(ex, "Publish error"); } }