|
|
|
@ -70,6 +70,11 @@ void PosDb::acceptLogEntry(const LogEntry & l) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case ET_PRICE: { |
|
|
|
|
upc_to_price[l.PriceChange.upc] = l.PriceChange.price; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case ET_REVERT: { |
|
|
|
|
sto_it q = serial_to_object.find(l.Revert.revert_serial); |
|
|
|
|
if((q == serial_to_object.end()) || (q->second.type != ET_TRANS)) { |
|
|
|
@ -172,7 +177,7 @@ uint64_t PosDb::deassociateHash(const SHA1Hash & hash) { |
|
|
|
|
} else { |
|
|
|
|
LogEntry l; |
|
|
|
|
memset(&l, 0, sizeof(LogEntry)); |
|
|
|
|
l.ts = (uint64_t)time(NULL); |
|
|
|
|
l.ts = (uint64_t)time(NULL); |
|
|
|
|
l.type = ET_HASH; |
|
|
|
|
l.HashChange.uid = acct; |
|
|
|
|
l.HashChange.add = false; |
|
|
|
@ -184,6 +189,26 @@ uint64_t PosDb::deassociateHash(const SHA1Hash & hash) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int32_t PosDb::getUPCPrice(UPC upc) { |
|
|
|
|
uts_it it = upc_to_price.find(upc); |
|
|
|
|
if (it == upc_to_price.end()) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
return it->second; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint64_t PosDb::setUPCPrice(UPC upc, int32_t price) { |
|
|
|
|
LogEntry l; |
|
|
|
|
memset(&l, 0, sizeof(LogEntry)); |
|
|
|
|
l.ts = (uint64_t)time(NULL); |
|
|
|
|
l.type = ET_PRICE; |
|
|
|
|
l.PriceChange.upc = upc; |
|
|
|
|
l.PriceChange.price = price; |
|
|
|
|
l.serial = log.nextSerial(); |
|
|
|
|
acceptLogEntry(l); |
|
|
|
|
return log.writeEntry(l); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint64_t PosDb::doTransaction(const SHA1Hash & hash, int32_t delta) { |
|
|
|
|
// verify hash associated with something
|
|
|
|
|
uint32_t acct = getAccountFromHash(hash); |
|
|
|
|