示例#1
0
        public TransactionResultTypes PublishMaintainTransaction(MaintainTransaction transaction)
        {
            transaction.SignKey      = ServiceChain.KeyStore.DecryptedKey;
            transaction.SignKeyIndex = ServiceChain.KeyStore.KeyIndex;

            var message = new NodeTransactionMessage(transaction)
            {
                SignKey = _node.NodeConfiguration.LocaleNodePrivateKey
            };

            // generate signatures
            message.ToByteArray();

            return(_node.TransactionManager.AddNodeTransaction(message, null));
        }
        public override void NewBlockAvailable(VoteProcess <ServiceBlock> voteProcess, BlockData <ServiceBlock> blockData, BlockProposalSignatures blockProposalSignatures)
        {
            base.NewBlockAvailable(voteProcess, blockData, blockProposalSignatures);

            var block = blockData.Block;

            if (block.Issuer == LocalKeyIndex)
            {
                var message = new NodeTransactionMessage(new ServiceBlockCoreTransaction(blockData.Block, blockProposalSignatures, _chainAccountId)
                {
                    SignKey = _localKey
                });
                message.ToByteArray();

                _node.TransactionManager.AddNodeTransaction(message, null);
                _ = _node.NodeServer.Broadcast(message, null);
            }
        }
        public TransactionResultTypes AddNodeTransaction(NodeTransactionMessage message, NodeConnection connection)
        {
            var transaction = message.Transaction;

            var check = PreCheck(transaction);

            if (check != TransactionResultTypes.Ok)
            {
                return(check);
            }

            if (transaction.IsCoreTransaction())
            {
                lock (_lock)
                    _coreTransactions.Add(new CoreItem(message.Hops, SenderTypes.Node, transaction as CoreTransaction, connection));
                return(TransactionResultTypes.Ok);
            }

            if (transaction.IsServiceTransaction())
            {
                lock (_lock)
                    _serviceTransactions.Add(new ServiceItem(message.Hops, SenderTypes.Node, transaction as ServiceTransaction, connection));
            }

            if (transaction.IsDataTransaction())
            {
                lock (_lock)
                    _dataTransactions.Add(new DataItem(message.Hops, SenderTypes.Node, transaction as DataTransaction, message.Payload?.Validation, connection));
                return(TransactionResultTypes.Ok);
            }

            if (transaction.IsMaintainTransaction())
            {
                lock (_lock)
                    _maintainTransactions.Add(new MaintainItem(message.Hops, transaction as MaintainTransaction, connection));
                return(TransactionResultTypes.Ok);
            }

            return(TransactionResultTypes.InvalidTransaction);
        }
示例#4
0
 Task OnNodeTransaction(NodeTransactionMessage message, NodeConnection connection)
 {
     _transactionManager.AddNodeTransaction(message, connection);
     return(Task.CompletedTask);
 }