//--------------------------------------------------------------------------------
    private bool print_pool_sh(List <string> args)
    {
        Console.Write("Pool short state: \n");
        var pool = m_core.getPoolTransactions();

        foreach (var tx in pool)
        {
            CryptoNote.CachedTransaction ctx = new CryptoNote.CachedTransaction(new Transaction(tx));
            Console.Write(GlobalMembers.printTransactionShortInfo(ctx));
            Console.Write("\n");
        }

        Console.Write("\n");

        return(true);
    }
Пример #2
0
        public override List <Crypto.Hash> clean(uint height)
        {
            try
            {
                ulong currentTime       = timeProvider.now();
                var   transactionHashes = transactionPool.getTransactionHashes();

                List <Crypto.Hash> deletedTransactions = new List <Crypto.Hash>();
                foreach (var hash in transactionHashes)
                {
                    ulong transactionAge = currentTime - transactionPool.getTransactionReceiveTime(hash);
                    if (transactionAge >= timeout)
                    {
                        logger.functorMethod(Logging.Level.DEBUGGING) << "Deleting transaction " << Common.GlobalMembers.podToHex(hash) << " from pool";
                        recentlyDeletedTransactions.Add(hash, currentTime);
                        transactionPool.removeTransaction(hash);
                        deletedTransactions.emplace_back(std::move(hash));
                    }

                    CachedTransaction        transaction  = transactionPool.getTransaction(hash);
                    List <CachedTransaction> transactions = new List <CachedTransaction>();
                    transactions.emplace_back(transaction);

                    var(success, error) = Mixins.validate(new List <CachedTransaction>(transactions), new uint(height));

                    if (!success)
                    {
                        logger.functorMethod(Logging.Level.DEBUGGING) << "Deleting invalid transaction " << Common.GlobalMembers.podToHex(hash) << " from pool." << error;
                        recentlyDeletedTransactions.Add(hash, currentTime);
                        transactionPool.removeTransaction(hash);
                        deletedTransactions.emplace_back(std::move(hash));
                    }
                }

                cleanRecentlyDeletedTransactions(new ulong(currentTime));
                return(deletedTransactions);
            }
            catch (System.InterruptedException)
            {
                throw;
            }
            catch (System.Exception e)
            {
                logger.functorMethod(Logging.Level.WARNING) << "Caught an exception: " << e.Message << ", stopping cleaning procedure cycle";
                throw;
            }
        }
Пример #3
0
        /* This method is commonly used by the node to determine if the transaction has
         * the correct mixin (anonymity) as defined by the current rules */
        public static Tuple <bool, string> validate(CachedTransaction transaction, ulong minMixin, ulong maxMixin)
        {
            ulong ringSize = 1;

            var tx = createTransaction(transaction.getTransaction());

            for (uint i = 0; i < tx.getInputCount(); ++i)
            {
                if (tx.getInputType(i) != TransactionTypes.InputType.Key)
                {
                    continue;
                }

                KeyInput input = new KeyInput();
                tx.getInput(i, input);
                ulong currentRingSize = input.outputIndexes.Count;
                if (currentRingSize > ringSize)
                {
                    ringSize = currentRingSize;
                }
            }

            /* Ring size = mixin + 1 - your transaction plus the others you mix with */
            ulong mixin = ringSize - 1;

            std::stringstream str = new std::stringstream();

            if (mixin > maxMixin)
            {
                str << "Transaction " << transaction.getTransactionHash() << " is not valid. Reason: transaction mixin is too large (" << (int)mixin << "). Maximum mixin allowed is " << (int)maxMixin;

                return(new Tuple <bool, string>(false, str.str()));
            }
            else if (mixin < minMixin)
            {
                str << "Transaction " << transaction.getTransactionHash() << " is not valid. Reason: transaction mixin is too small (" << (int)mixin << "). Minimum mixin allowed is " << (int)minMixin;

                return(new Tuple <bool, string>(false, str.str()));
            }

            return(new Tuple <bool, string>(true, string()));
        }
    //--------------------------------------------------------------------------------
    private bool print_tx(List <string> args)
    {
        if (args.Count == 0)
        {
            Console.Write("expected: print_tx <transaction hash>");
            Console.Write("\n");
            return(true);
        }

        string str_hash = args[0];

        Crypto.Hash tx_hash = new Crypto.Hash();
        if (!parse_hash256(str_hash, tx_hash))
        {
            return(true);
        }

        List <Crypto.Hash> tx_ids = new List <Crypto.Hash>();

        tx_ids.Add(tx_hash);
        List <List <ushort> > txs        = new List <List <ushort> >();
        List <Crypto.Hash>    missed_ids = new List <Crypto.Hash>();

        m_core.getTransactions(tx_ids, txs, missed_ids);

        if (1 == txs.Count)
        {
            CryptoNote.CachedTransaction tx = new CryptoNote.CachedTransaction(new List <List <ushort> >(txs[0]));
            GlobalMembers.print_as_json(tx.getTransaction());
        }
        else
        {
            Console.Write("transaction wasn't found: <");
            Console.Write(str_hash);
            Console.Write('>');
            Console.Write("\n");
        }

        return(true);
    }
Пример #5
0
//C++ TO C# CONVERTER TODO TASK: 'rvalue references' have no equivalent in C#:
        public override bool pushTransaction(CachedTransaction && tx, TransactionValidatorState&& transactionState)
        {
            return(!isTransactionRecentlyDeleted(tx.getTransactionHash()) && transactionPool.pushTransaction(std::move(tx), std::move(transactionState)));
        }
Пример #6
0
//C++ TO C# CONVERTER TODO TASK: 'rvalue references' have no equivalent in C#:
        public bool pushTransaction(CachedTransaction && transaction, TransactionValidatorState&& transactionState)
        {
            var pendingTx = new PendingTransactionInfo({ (ulong)time(null), std::move(transaction) });