*/
Digest computeMessageDigest(long[] highest_seqnos) {
Digest digest=highest_seqnos != null? new Digest(highest_seqnos.length) : null;
Address sender;
NakReceiverWindow win;
List unstable_msgs;
int own_index;
long highest_seqno_sent=-1, highest_seqno_received=-1;
if(digest == null) {
if(warn) log.warn("highest_seqnos is null, cannot compute digest !");
return null;
}
if(highest_seqnos.length != members.size()) {
if(warn) log.warn("the mbrship size and the size " +
"of the highest_seqnos array are not equal, cannot compute digest !");
return null;
}
System.arraycopy(highest_seqnos, 0, digest.highest_seqnos, 0, digest.highest_seqnos.length);
for(int i=0; i < highest_seqnos.length; i++) {
sender=(Address)members.elementAt(i);
if(sender == null) continue;
win=(NakReceiverWindow)received_msgs.get(sender);
if(win == null) continue;
digest.highest_seqnos[i]=win.getHighestReceived();
unstable_msgs=win.getMessagesHigherThan(highest_seqnos[i]);
for(Enumeration e=unstable_msgs.elements(); e.hasMoreElements();)
digest.msgs.add(e.nextElement());
}
/** If our highest seqno <em>sent</em> is higher than the one <em>received</em>, we have to
(a) set it in the digest and (b) add the corresponding messages **/
own_index=members.indexOf(local_addr);
if(own_index == -1) {
if(warn) log.warn("no own address in highest_seqnos");
return digest;
}
highest_seqno_received=digest.highest_seqnos[own_index];
highest_seqno_sent=getHighestSeqnoSent();
if(highest_seqno_sent > highest_seqno_received) {
// (a) Set highest seqno sent in digest
digest.highest_seqnos[own_index]=highest_seqno_sent;
// (b) Add messages between highest_seqno_received and highest_seqno_sent
unstable_msgs=getSentMessagesHigherThan(highest_seqno_received);
for(Enumeration e=unstable_msgs.elements(); e.hasMoreElements();)
digest.msgs.add(e.nextElement());
}
return digest;
}