private Transaction CreateReportMaliciousTransactionCore(PersistentReport persistentReport) { var transaction = ValidatorContract.ReportMalicious(persistentReport.ValidatorAddress, persistentReport.BlockNumber, persistentReport.Proof); transaction.Nonce = _stateProvider.GetNonce(ValidatorContract.NodeAddress); return(transaction); }
private Transaction CreateReportMaliciousTransaction(Address validator, long blockNumber, byte[] proof) { if (!Validators.Contains(validator)) { if (_logger.IsWarn) { _logger.Warn($"Not reporting {validator} on block {blockNumber}: Not a validator"); } return(null); } var persistentReport = new PersistentReport(validator, (UInt256)blockNumber, proof); if (IsPosdao(blockNumber)) { _persistentReports.AddLast(persistentReport); } return(CreateReportMaliciousTransactionCore(persistentReport)); }
private void UpdateStorageReportCellValue(PurchaseObject purchaseData, int userId, int reportRowId, int reportColId = 0 /*reportColId is optional*/) { int IdentifierId = (int)PersistReportType.Storage; int PartId = (int)PersistReportPart.Part1; int rowId = reportRowId; int colId = reportColId == 0 ? purchaseData.SpiritTypeReportingID : reportColId; if (rowId == 0 || colId == 0) { throw new ArgumentOutOfRangeException("Reporting row ID and column ID must be greater than 0"); } // converting to PST DateTimeOffset purchDate = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(purchaseData.PurchaseDate, "Pacific Standard Time"); // adding 1 month to update OnHandFirstOfMonth for next month DateTimeOffset nextMonth = purchDate.AddMonths(1); float proofGal = purchaseData.ProofGallon; if (purchaseData != null) { try { // checking for existing row with these values var reportRec = (from rec in _context.PersistentReport where (rec.IdentifierID == IdentifierId && rec.PartID == PartId && rec.RowID == rowId && rec.ColumnID == colId && rec.Date.Year == purchDate.Year && rec.Date.Month == purchDate.Month) select rec).FirstOrDefault(); var firstOfMonthRec = (from rec in _context.PersistentReport where (rec.IdentifierID == IdentifierId && rec.PartID == PartId && rec.RowID == rowId && rec.ColumnID == colId && rec.Date.Year == nextMonth.Year && rec.Date.Month == nextMonth.Month) select rec).FirstOrDefault(); if (rowId == (int)PersistReportRow.OnHandFirstOfMonth && firstOfMonthRec != null) { firstOfMonthRec.Value += proofGal; } else if (reportRec == null) { PersistentReport cellValue = new PersistentReport(); cellValue.IdentifierID = IdentifierId; cellValue.PartID = PartId; cellValue.RowID = rowId; cellValue.ColumnID = colId; cellValue.Value = purchaseData.ProofGallon; if (rowId == (int)PersistReportRow.OnHandFirstOfMonth) { cellValue.DateOffset = nextMonth; cellValue.Date = nextMonth.Date; } else { cellValue.DateOffset = purchDate; cellValue.Date = purchDate.Date; } cellValue.DistillerID = _dl.GetDistillerId(userId); _context.PersistentReport.Add(cellValue); } else { reportRec.Value += proofGal; } } catch (Exception e) { throw e; } } }