コード例 #1
0
        /// <summary>
        /// Notifies message author(s) about message processing result
        /// </summary>
        /// <param name="result">Result message</param>
        public static void OnMessageProcessResult(this AlphaContext context, ResultMessage result)
        {
            if (result == null)
            {
                return;
            }
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var signatures = result.OriginalMessage.Signatures;

            //unwrap if it is RequestQuantum
            if (result.OriginalMessage.Message is RequestQuantum)
            {
                signatures = ((RequestQuantum)result.OriginalMessage.Message).RequestEnvelope.Signatures;
            }
            var envelope = result.CreateEnvelope();

            for (var i = 0; i < signatures.Count; i++)
            {
                var accountToNotify = signatures[i];
                context.Notify(accountToNotify.Signer, envelope);
            }
        }
コード例 #2
0
 /// <summary>
 /// Sends the message to the account
 /// </summary>
 /// <param name="account">Target account</param>
 /// <param name="envelope">Message to send</param>
 public static void Notify(this AlphaContext context, RawPubKey account, MessageEnvelope envelope)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     context.ExtensionsManager.BeforeNotify(account, envelope);
     if (context.ConnectionManager.TryGetConnection(account, out AlphaWebSocketConnection connection))
     {
         Task.Factory.StartNew(async() => await connection.SendMessage(envelope)).Unwrap();
     }
 }
コード例 #3
0
        /// <summary>
        /// Sends the message to all connected auditors
        /// </summary>
        /// <param name="envelope">Message to send</param>
        public static void NotifyAuditors(this AlphaContext context, MessageEnvelope envelope)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            context.ExtensionsManager.BeforeNotifyAuditors(envelope);
            var auditors = context.ConnectionManager.GetAuditorConnections();

            for (var i = 0; i < auditors.Count; i++)
            {
                var auditor = auditors[i];
                Task.Factory.StartNew(async() => await auditor.SendMessage(envelope)).Unwrap();
            }
        }
コード例 #4
0
            private RawPubKey GetMessageAccount(AlphaContext context)
            {
                var originalEnvelope = ResultMessage.OriginalMessage;
                SequentialRequestMessage requestMessage = null;

                if (originalEnvelope.Message is SequentialRequestMessage)
                {
                    requestMessage = (SequentialRequestMessage)originalEnvelope.Message;
                }
                else if (originalEnvelope.Message is RequestQuantum)
                {
                    requestMessage = ((RequestQuantum)originalEnvelope.Message).RequestEnvelope.Message as SequentialRequestMessage;
                }

                if (requestMessage == null)
                {
                    return(null);
                }
                return(context.AccountStorage.GetAccount(requestMessage.Account).Account.Pubkey);
            }
コード例 #5
0
 public AuditorResultsBatchHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #6
0
 public AuditLedgerManager(AlphaContext context)
     : base(context)
 {
     alphaListener = (AlphaTxListener)context.TxListener;
     Task.Factory.StartNew(TryHandleTxCommit, TaskCreationOptions.LongRunning);
 }
コード例 #7
0
 public OrderMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #8
0
 public AccountDataRequestHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #9
0
 public OrderCancellationMessageHandler(AlphaContext context) 
     : base(context)
 {
 }
コード例 #10
0
 public UnsubscribeCommandHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #11
0
 public PaymentMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #12
0
 public ResultMessageItem(MessageEnvelope resultEnvelope, byte[] messageHash, Dictionary <int, Message> notifications, AlphaContext context)
 {
     ResultEnvelope    = resultEnvelope ?? throw new ArgumentNullException(nameof(resultEnvelope));
     Hash              = messageHash;
     IsTxResultMessage = resultEnvelope.Message is ITransactionResultMessage;
     AccountPubKey     = GetMessageAccount(context);
     Notifications     = notifications ?? throw new ArgumentNullException(nameof(notifications));
 }
コード例 #13
0
 public AuditorStateMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #14
0
 public WithdrawalMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #15
0
 public AlphaEffectsRequestMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #16
0
 public AuditorPerfStatisticsMessageHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #17
0
 public GetPriceHistoryCommandHandler(AlphaContext context)
     : base(context)
 {
 }
コード例 #18
0
 protected AlphaBaseQuantumHandler(AlphaContext context)
     : base(context)
 {
 }