blocksNotSentButPresent = prb.cloneBlocksReceived();
prb.add(this);
}
try {
prb.usm.addAsyncFilter(MessageFilter.create().setNoTimeout().setSource(peer).setType(DMT.FNPBulkReceiveAborted).setField(DMT.UID, uid),
new AsyncMessageFilterCallback() {
@Override
public void onMatched(Message m) {
cancel("Other side sent FNPBulkReceiveAborted");
}
@Override
public boolean shouldTimeout() {
synchronized(BulkTransmitter.this) {
if(cancelled || finished) return true;
}
if(BulkTransmitter.this.prb.isAborted()) return true;
return false;
}
@Override
public void onTimeout() {
// Ignore
}
@Override
public void onDisconnect(PeerContext ctx) {
// Ignore
}
@Override
public void onRestarted(PeerContext ctx) {
// Ignore
}
}, ctr);
prb.usm.addAsyncFilter(MessageFilter.create().setNoTimeout().setSource(peer).setType(DMT.FNPBulkReceivedAll).setField(DMT.UID, uid),
new AsyncMessageFilterCallback() {
@Override
public void onMatched(Message m) {
// send() will terminate, so must call setAllQueued().
setAllQueued();
completed();