import java.util.Arrays;
class Slot {
- public static final int SLOT_SIZE=2048;
- public static final int HMAC_SIZE=32;
+ static final int SLOT_SIZE=2048;
+ static final int HMAC_SIZE=32;
private long seqnum;
private byte[] prevhmac;
private byte[] hmac;
private long machineid;
private Vector<Entry> entries;
-
- Slot(long _seqnum, long _machineid, byte[] _prevhmac, byte[] _hmac, Vector<Entry> _entries) {
+ private int livecount;
+
+ Slot(long _seqnum, long _machineid, byte[] _prevhmac, byte[] _hmac) {
seqnum=_seqnum;
machineid=_machineid;
prevhmac=_prevhmac;
hmac=_hmac;
- entries=_entries;
+ entries=new Vector<Entry>();
+ livecount=1;
}
Slot(long _seqnum, byte[] _bytes) {
return prevhmac;
}
+ void addEntry(Entry e) {
+ entries.add(e);
+ livecount++;
+ }
+
Vector<Entry> getEntries() {
return entries;
}
long seqnum=bb.getLong();
long machineid=bb.getLong();
int numentries=bb.getInt();
- Vector<Entry> entries=new Vector<Entry>();
+ Slot slot=new Slot(seqnum, machineid, prevhmac, hmac);
+
for(int i=0;i<numentries;i++) {
- entries.add(Entry.decode(bb));
+ slot.addEntry(Entry.decode(slot, bb));
}
- return new Slot(seqnum, machineid, prevhmac, hmac, entries);
+ return slot;
}
byte[] encode(Mac mac) {
byte[] getBytes() {
return null;
}
+
+ void decrementLiveCount() {
+ livecount--;
+ }
+ boolean isLive() {
+ return livecount > 0;
+ }
+
public String toString() {
return "<"+getSequenceNumber()+", "+new String(getBytes())+">";
}