public static void AddFraudReportToStorage(byte[] fraudId, byte[] reporter, byte[] fakeButValidCertificateHash) { FraudEntry fraudEntry = new FraudEntry(); fraudEntry.FraudId = fraudId; fraudEntry.Reporter = reporter; fraudEntry.FakeButValidCertificateHash = fakeButValidCertificateHash; fraudEntry.ReportDate = TransactionContentUtil.retrieveTransactionTime(); fraudEntry.Status = FraudStatus.REPORTED; byte[] fraudIdStorageKey = ArrayUtil.Concat(FRAUD_ID_STORAGE_PREFIX, fraudId); saveStorageForFraudIdIndex(fraudIdStorageKey, fraudEntry); AddFraudToList(FRAUD_LIST_STORAGE_KEY, fraudIdStorageKey); }
public static FraudEntry ReadFraudEntry(byte[] fraudId) { FraudEntry fraudEntry = new FraudEntry(); byte[] fraudIdStorageKey = ArrayUtil.Concat(FRAUD_ID_STORAGE_PREFIX, fraudId); byte[] fraudEntrySerialized = StorageUtil.readFromStorage(fraudIdStorageKey); if (fraudEntrySerialized == null) { return(fraudEntry); } return((FraudEntry)SerializationUtil.Deserialize(fraudEntrySerialized)); }
public static void updateFraudEntry(FraudEntry fraudEntry) { byte[] fraudIdStorageKey = ArrayUtil.Concat(FRAUD_ID_STORAGE_PREFIX, fraudEntry.FraudId); saveStorageForFraudIdIndex(fraudIdStorageKey, fraudEntry); }
private static void saveStorageForFraudIdIndex(byte[] fraudIdStorageKey, FraudEntry fraudEntry) { byte[] fraudEntrySerialized = SerializationUtil.Serialize(fraudEntry); StorageUtil.saveToStorage(fraudIdStorageKey, fraudEntrySerialized); }