#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),
freespace(SLOT_SIZE - getBaseSize()),
table(_table),
localSequenceNumber(_localSequenceNumber) {
- }
+}
Slot::Slot(Table *_table, int64_t _seqnum, int64_t _machineid, int64_t _localSequenceNumber) :
seqnum(_seqnum),
freespace(SLOT_SIZE - getBaseSize()),
table(_table),
localSequenceNumber(_localSequenceNumber) {
- }
+}
Entry *Slot::addEntry(Entry *e) {
e = e->getCopy(this);
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);
return slot;
}
-Array<char> *Slot::encode(Mac * mac) {
+Array<char> *Slot::encode(Mac *mac) {
Array<char> *array = new Array<char>(SLOT_SIZE);
ByteBuffer *bb = ByteBuffer_wrap(array);
/* Leave space for the slot HMAC. */
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);