Пример #1
0
        protected async Task BCPTransfer(string chainHash, UInt160 targetAddress, Fixed8 gasPrice)
        {
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitSysCall("Zoro.NativeNEP5.Call", "Transfer", Genesis.BcpContractAddress, scriptHash, targetAddress, BigInteger.Parse(transferValue));

                RelayResultReason result = await ZoroHelper.SendInvocationTransaction(sb.ToArray(), keypair, chainHash, GasLimit["BCPTransfer"], gasPrice);

                ParseResult(result);
            }
        }
Пример #2
0
        protected async Task NEP5Transfer(string chainHash, UInt160 targetAddress, Fixed8 gasPrice)
        {
            using (ScriptBuilder sb = new ScriptBuilder())
            {
                sb.EmitAppCall(nep5ContractHash, "transfer", scriptHash, targetAddress, BigInteger.Parse(transferValue));

                RelayResultReason result = await ZoroHelper.SendInvocationTransaction(sb.ToArray(), keypair, chainHash, GasLimit["NEP5Transfer"], gasPrice);

                ParseResult(result);
            }
        }
Пример #3
0
        private bool OnStressTestingCommand(string[] args)
        {
            if (Settings.Default.EnableManualParam == 1)
            {
                Console.Write("Transaction Type, 0 - NEP5 SmartContract, 1 - NativeNEP5, 2 - BCP:");
                var param1 = Console.ReadLine();
                Console.Write("Concurrency count:");
                var param2 = Console.ReadLine();
                Console.Write("Totoal transaction count:");
                var param3 = Console.ReadLine();
                Console.Write("Transfer value:");
                var param4 = Console.ReadLine();
                Console.Write("Random target address, 0 - no, 1 - yes:");
                var param5 = Console.ReadLine();
                Console.Write("Random gas price, 0 - no, 1 - yes:");
                var param6 = Console.ReadLine();

                transactionType     = int.Parse(param1);
                transferCount       = int.Parse(param3);
                concurrencyCount    = int.Parse(param2);
                transferValue       = param4;
                randomTargetAddress = int.Parse(param5) == 1;
                randomGasPrice      = int.Parse(param6) == 1;
            }
            else
            {
                transactionType     = Settings.Default.TransactionType;
                transferCount       = Settings.Default.TransferCount;
                concurrencyCount    = Settings.Default.ConcurrencyCount;
                transferValue       = Settings.Default.TransferValue.ToString();
                randomTargetAddress = Settings.Default.RandomTargetAddress == 1;
                randomGasPrice      = Settings.Default.RandomGasPrice == 1;
            }

            preventOverflow  = Settings.Default.PreventOverflow == 1;
            printErrorReason = Settings.Default.PrintErrorReason == 1;

            string chainHash = Settings.Default.TargetChainHash;
            string WIF       = Settings.Default.WIF;
            string targetWIF = Settings.Default.TargetWIF;

            keypair       = ZoroHelper.GetKeyPairFromWIF(WIF);
            scriptHash    = ZoroHelper.GetPublicKeyHash(keypair.PublicKey);
            targetAddress = ZoroHelper.GetPublicKeyHashFromWIF(targetWIF);

            nep5ContractHash  = UInt160.Parse(Settings.Default.NEP5Hash);
            nativeNEP5AssetId = UInt160.Parse(Settings.Default.NativeNEP5Hash);

            Blockchain blockchain = ZoroChainSystem.Singleton.GetBlockchain(chainHash);

            if (blockchain == null)
            {
                return(true);
            }

            if (randomTargetAddress)
            {
                PluginManager.EnableLog(false);

                InitializeRandomTargetAddressList(transferCount);

                PluginManager.EnableLog(true);
            }

            if (transactionType == 0 || transactionType == 1 || transactionType == 2)
            {
                Console.WriteLine($"From:{WIF}");
                Console.WriteLine($"To:{targetWIF}");
                Console.WriteLine($"Count:{transferCount}");
                Console.WriteLine($"Value:{transferValue}");
            }

            cancelTokenSource = new CancellationTokenSource();

            Task.Run(() => RunTask(chainHash, blockchain));

            Console.WriteLine("Input [enter] to stop:");
            var input = Console.ReadLine();

            cancelTokenSource.Cancel();

            return(true);
        }