currentDataSize(0) {
}
+PendingTransaction::~PendingTransaction() {
+ delete keyValueUpdateSet;
+ delete keyValueGuardSet;
+}
+
/**
* Add a new key value to the updates
*
*/
void PendingTransaction::addKV(KeyValue *newKV) {
-
KeyValue *rmKV = NULL;
// Make sure there are no duplicates
while (kvit->hasNext()) {
KeyValue *kv = kvit->next();
if (kv->getKey()->equals(newKV->getKey())) {
-
// Remove key if we are adding a newer version of the same key
rmKV = kv;
break;
arbitrator = arb;
return true;
}
-
return arb == arbitrator;
}
SetIterator<KeyValue *> *kvit = keyValueGuardSet->iterator();
while (kvit->hasNext()) {
KeyValue *kvGuard = kvit->next();
-
- // First check if the key is in the speculative table, this is the value of the latest assumption
+ // First check if the key is in the speculative table, this is the
+ // value of the latest assumption
KeyValue *kv = keyValTablePendingTransSpeculative->get(kvGuard->getKey());
if (kv == NULL) {
- // if it is not in the pending trans table then check the speculative table and use that
- // value as our latest assumption
+ // if it is not in the pending trans table then check the
+ // speculative table and use that value as our latest assumption
kv = keyValTableSpeculative->get(kvGuard->getKey());
}
if (kv == NULL) {
- // if it is not in the speculative table then check the committed table and use that
- // value as our latest assumption
+ // if it is not in the speculative table then check the
+ // committed table and use that value as our latest assumption
kv = keyValTableCommitted->get(kvGuard->getKey());
}
Array<char> *charData = convertDataToBytes();
int currentPosition = 0;
- int remaining = charData->length();
-
- while (remaining > 0) {
-
+ for(int remaining = charData->length(); remaining > 0;) {
bool isLastPart = false;
// determine how much to copy
int copySize = TransactionPart_MAX_NON_HEADER_SIZE;
if (remaining <= TransactionPart_MAX_NON_HEADER_SIZE) {
copySize = remaining;
- isLastPart = true;// last bit of data so last part
+ isLastPart = true;//last bit of data so last part
}
-
+
// Copy to a smaller version
Array<char> *partData = new Array<char>(copySize);
System_arraycopy(charData, currentPosition, partData, 0, copySize);
return bbEncode->array();
}
-
#include "CloudComm.h"
#include "Table.h"
#include "LastMessage.h"
+#include "Mac.h"
Slot::Slot(Table *_table, int64_t _seqnum, int64_t _machineid, Array<char> *_prevhmac, Array<char> *_hmac, int64_t _localSequenceNumber) :
seqnum(_seqnum),
return entries;
}
-Slot *Slotdecode(Table *table, Array<char> *array, Mac *mac) {
- mac->update(array, HMAC_SIZE, array.length - HMAC_SIZE);
+Slot *Slot_decode(Table *table, Array<char> *array, Mac *mac) {
+ mac->update(array, HMAC_SIZE, array->length() - HMAC_SIZE);
Array<char> *realmac = mac->doFinal();
ByteBuffer *bb = ByteBuffer_wrap(array);
bb->putLong(seqnum);
bb->putLong(machineid);
bb->putInt(entries->size());
- for (Entry *entry : entries) {
+ for(uint ei=0; ei < entries->size(); ei++) {
+ Entry * entry = entries->get(ei);
entry->encode(bb);
}
/* Compute our HMAC */
- mac->update(array, HMAC_SIZE, array.length - HMAC_SIZE);
+ mac->update(array, HMAC_SIZE, array->length() - HMAC_SIZE);
Array<char> *realmac = mac->doFinal();
hmac = realmac;
bb->position(0);
Vector<Entry *> *Slot::getLiveEntries(bool resize) {
Vector<Entry *> *liveEntries = new Vector<Entry *>();
- for (Entry *entry : entries) {
+ for(uint ei=0; ei < entries->size(); ei++) {
+ Entry * entry = entries->get(ei);
if (entry->isLive()) {
if (!resize || entry->getType() != TypeTableStatus)
liveEntries->add(entry);
#include "common.h"
#include "Liveness.h"
-
#define SLOT_SIZE 2048
#define HMAC_SIZE 32
void decrementLiveCount();
bool isLive() { return livecount > 0; }
Array<char> *getSlotCryptIV();
- friend Slot *Slotdecode(Table *table, Array<char> *array, Mac *mac);
+ friend Slot *Slot_decode(Table *table, Array<char> *array, Mac *mac);
};
-Slot *Slotdecode(Table *table, Array<char> *array, Mac *mac);
+Slot *Slot_decode(Table *table, Array<char> *array, Mac *mac);
#endif