protected override void ProcessTransactionTx(TxModel tx) { try { if (Context.AppState.State == ApplicationState.Failed) { listener.Shutdown(); return; } RegisterNewCursor(tx.PagingToken); } catch (Exception exc) { var e = exc; if (exc is AggregateException) { e = exc.GetBaseException(); } logger.Error(e, "Transaction listener failed."); //if worker is broken, the auditor should quit consensus Context.AppState.State = ApplicationState.Failed; listener?.Shutdown(); throw; } }
public async Task <IActionResult> SendTx([FromBody] TxModel txModel) { try { if (ModelState.IsValid) { var transacInpunt = new Nethereum.RPC.Eth.DTOs.TransactionInput { From = txModel.SenderAddress, To = txModel.ToAddress, Value = new HexBigInteger(txModel.Value) }; var tx = await Web3Client.Eth.Transactions.SendTransaction.SendRequestAsync(transacInpunt); return(Json(tx)); } return(BadRequest(ModelState)); } catch (Exception ex) { return(ReturnError(ex)); } }
/// <summary> /// Converts Raw Transaction hex into a JSON string representation of the transaction. /// </summary> private void SetJson() { try { TxModel btx = TxService.DecodeRawTx(rawTx); TxJson = JsonConvert.SerializeObject(btx, Formatting.Indented); } catch (Exception ex) { TxJson = "Not a Valid Transaction hex" + Environment.NewLine + ex.ToString(); } }
/// <summary> /// パラメータの設定 /// </summary> /// <param name="name">パラメータ名称</param> /// <param name="value">設定値</param> public void SetParam(string name, object value) { TxModel model = ModelOf.From(value.GetType()); switch (model.Type) { case ExType.None: throw new CxException(ExStatus.Unsupported); case ExType.Ptr: break; default: break; } }
public async Task <IActionResult> SendTx([FromBody] TxModel txModel) { try { //TODO: Implement! //Tips: // - get transaction count // - build and sign the tx OfflineTransactionSigner // - Send the tx using SendRawTransaction return(null); } catch (Exception ex) { return(ReturnError(ex)); } }
/// <summary> /// Deserialize the transaction hex string. /// </summary> /// <param name="rawTx">Transaction hex string</param> /// <returns>Bitcoin Transaction</returns> public static TxModel DecodeRawTx(string rawTx) { if (Transaction.TryParse(Base16.ToByteArray(rawTx), out Transaction tx)) { TxModel result = new TxModel() { Version = tx.Version, TxInCount = tx.TxInCount.Number, TxInList = new ObservableCollection <TxInModel>(tx.TxInList.Select(x => new TxInModel(x))), TxOutCount = tx.TxOutCount.Number, TxOutList = new ObservableCollection <TxOut>(tx.TxOutList), LockTime = tx.LockTime, TxId = tx.GetTransactionID(), WtxId = tx.GetWitnessTransactionID(), IsRbf = tx.TxInList.Any(x => x.Sequence != uint.MaxValue) }; return(result); } throw new ArgumentException("Can not parse the given transaction!"); }
protected override void ProcessTransactionTx(TxModel tx) { try { if (Context.AppState.State == ApplicationState.Failed) { listener.Shutdown(); return; } var payments = AddVaultPayments(Transaction.FromEnvelopeXdr(tx.EnvelopeXdr), tx.IsSuccess); var payment = new TxNotification { TxCursor = tx.PagingToken, Payments = payments }; logger.Trace($"Tx with hash {tx.Hash} is handled. Number of payments for account {Context.Constellation.Vault} is {payment.Payments.Count}."); AuditorContext.OutgoingMessageStorage.OnTransaction(payment); } catch (Exception exc) { var e = exc; if (exc is AggregateException) { e = exc.GetBaseException(); } logger.Error(e, "Transaction listener failed."); //if worker is broken, the auditor should quit consensus Context.AppState.State = ApplicationState.Failed; listener?.Shutdown(); throw; } }
public async Task SendGasFromCowAccountCreatedTest() { // Act var request = new TxModel() { SenderAddress = TestSettings.CowAccountAddress, ToAddress = TestSettings.NewAccountAddress, Value = TestSettings.GasAmountToSend }; var content = JsonConvert.SerializeObject(request); var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); var responseSendTx = await _client.PostAsync("api/Rsk/SendTx", stringContent); // Assert responseSendTx.EnsureSuccessStatusCode(); var responseSendTxString = await responseSendTx.Content.ReadAsStringAsync(); var responseTx = JsonConvert.DeserializeObject <string>(responseSendTxString); responseTx.Should().NotBeNullOrEmpty(); }
private void DataProvider_TxAdded(TxModel obj) { txs.Add(obj); }
protected abstract void ProcessTransactionTx(TxModel tx);
/// <summary> /// フォーマット(サイズ)リストの指標が変化したとき /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboFormatSize_SelectedIndexChanged(object sender, EventArgs e) { try { this.Grabber.Stop(); } catch (Exception) { } this.Grabber.Dispose(); lock (this.TimeStamps) { this.TimeStamps.Clear(); } this.statusTimeStamp.Text = ""; this.statusFps.Text = ""; FilterPair filter_pair = FilterPairs[comboFilter.SelectedIndex]; PinPair pin_pair = filter_pair.Value[comboPin.SelectedIndex]; FormatPair format_pair = pin_pair.Value[comboFormatColor.SelectedIndex]; CxDSFormatInfo format_info = format_pair.Value[comboFormatSize.SelectedIndex]; this.Backup.FilterInfo = filter_pair.Key; this.Backup.PinInfo = pin_pair.Key; this.Backup.FormatInfo = format_info; this.propertyParam.Refresh(); this.Grabber.Setup(); foreach (var image in this.Buffer) { image.Resize(this.Grabber.FrameSize.Width, this.Grabber.FrameSize.Height, TxModel.U8(4), 1); } this.Grabber.Capture(this.Buffer, true); this.Grabber.Start(); }
public void configure(String[] args) { // create app properties, using the default values as initial values appProperties = new Dictionary<String, String>(defaultProperties); // parse command line on top of defaults parseCommandLine(args, appProperties); // load properties from application.properties file over the defaults loadProperties(appProperties, PROPERTIES_PATH); // now load database properties file over the application and the defaults loadProperties(appProperties, DB_PROPERTIES_PATH); // parse the command line into app properties, as command line overrides all others parseCommandLine(args, appProperties); resolveReferences(appProperties); String[] keys = appProperties.Keys.ToArray(); Array.Sort(keys); String helpOption; if (appProperties.TryGetValue("help", out helpOption) && "true".Equals(helpOption, StringComparison.InvariantCultureIgnoreCase)) { Console.Out.WriteLine("\nCSNuoTest [option=value [, option=value, ...] ]\nwhere <option> can be any of:\n"); foreach (String key in keys) { Console.Out.WriteLine(String.Format("{0}\t\t\t\t(default={1})", key, defaultProperties[key])); } Console.Out.WriteLine("\nHelp called - nothing to do; exiting."); Environment.Exit(0); } appLog.info("command-line properties: {0}", string.Join(";", appProperties)); StringBuilder builder = new StringBuilder(1024); builder.Append("\n***************** Resolved Properties ********************\n"); foreach (String key in keys) { builder.AppendFormat("{0} = {1}\n", key, appProperties[key]); } appLog.info("{0}**********************************************************\n", builder.ToString()); runTime = Int32.Parse(appProperties[RUN_TIME]) * Millis; averageRate = Single.Parse(appProperties[AVERAGE_RATE]); minViewAfterInsert = Int32.Parse(appProperties[MIN_VIEW_DELAY]); maxViewAfterInsert = Int32.Parse(appProperties[MAX_VIEW_DELAY]); timingSpeedup = Single.Parse(appProperties[TIMING_SPEEDUP]); minGroups = Int32.Parse(appProperties[MIN_GROUPS]); maxGroups = Int32.Parse(appProperties[MAX_GROUPS]); minData = Int32.Parse(appProperties[MIN_DATA]); maxData = Int32.Parse(appProperties[MAX_DATA]); burstProbability = Single.Parse(appProperties[BURST_PROBABILITY_PERCENT]); minBurst = Int32.Parse(appProperties[MIN_BURST]); maxBurst = Int32.Parse(appProperties[MAX_BURST]); maxQueued = Int32.Parse(appProperties[MAX_QUEUED]); initDb = Boolean.Parse(appProperties[DB_INIT]); queryOnly = Boolean.Parse(appProperties[QUERY_ONLY]); queryBackoff = Int32.Parse(appProperties[QUERY_BACKOFF]); maxRetry = Int32.Parse(appProperties[MAX_RETRY]); retrySleep = Int32.Parse(appProperties[RETRY_SLEEP]); String threadParam; int insertThreads = (appProperties.TryGetValue(INSERT_THREADS, out threadParam) ? Int32.Parse(threadParam) : 1); int queryThreads = (appProperties.TryGetValue(QUERY_THREADS, out threadParam) ? Int32.Parse(threadParam) : 1); if (maxViewAfterInsert > 0 && maxViewAfterInsert < minViewAfterInsert) { maxViewAfterInsert = minViewAfterInsert; } if (maxBurst <= minBurst) { appLog.info("maxBurst ({0}) <= minBurst ({1}); burst disabled", maxBurst, minBurst); burstProbability = minBurst = maxBurst = 0; } // filter out database properties, and strip off the prefix Dictionary<String, String> dbProperties = new Dictionary<String, String>(); String dbPropertyPrefix = appProperties[DB_PROPERTY_PREFIX]; if (! dbPropertyPrefix.EndsWith(".")) dbPropertyPrefix = dbPropertyPrefix + "."; foreach (String key in appProperties.Keys) { if (key.StartsWith(dbPropertyPrefix)) { dbProperties[key.Substring(dbPropertyPrefix.Length)] = appProperties[key]; } } //String insertIsolation = appProperties.getProperty(UPDATE_ISOLATION); //DataSource dataSource = new com.nuodb.jdbc.DataSource(dbProperties); SqlSession.init(dbProperties, insertThreads + queryThreads); SqlSession.CommunicationMode commsMode; if (!Enum.TryParse<SqlSession.CommunicationMode>(appProperties[COMMUNICATION_MODE], out commsMode)) commsMode = SqlSession.CommunicationMode.SQL; SqlSession.globalCommsMode = commsMode; appLog.info("SqlSession.globalCommsMode set to {0}", commsMode); SqlSession.SpNamePrefix = appProperties[SP_NAME_PREFIX]; ownerRepository = new OwnerRepository(); ownerRepository.init(); groupRepository = new GroupRepository(); groupRepository.init(); dataRepository = new DataRepository(); dataRepository.init(); eventRepository = new EventRepository(ownerRepository, groupRepository, dataRepository); eventRepository.init(); if (!Enum.TryParse<TxModel>(appProperties[TX_MODEL], out txModel)) txModel = TxModel.DISCRETE; if (!Enum.TryParse<SqlSession.Mode>(appProperties[BULK_COMMIT_MODE], out bulkCommitMode)) bulkCommitMode = SqlSession.Mode.BATCH; //insertExecutor = Executors.newFixedThreadPool(insertThreads); //queryExecutor= Executors.newScheduledThreadPool(queryThreads); insertExecutor = new ThreadPoolExecutor<EventGenerator>("INSERT", insertThreads); queryExecutor = new ThreadPoolExecutor<EventViewTask>("QUERY", queryThreads); string checkOnly; if (appProperties.TryGetValue("check.config", out checkOnly) && checkOnly.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { Console.Out.WriteLine("CheckConfig called - nothing to do; exiting."); Environment.Exit(0); } string silent; if (appProperties.TryGetValue("silent", out silent) && silent.Equals("true", StringComparison.InvariantCultureIgnoreCase)) { Logger.Silent = true; } }