Skip to content

Commit 1a36305

Browse files
committed
routed messages are put into incoming storage of originator and instead of folder of last hop.
1 parent ca66cc4 commit 1a36305

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/net/sharksystem/asap/ASAPEngine.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public void handleASAPInterest(ASAP_Interest_PDU_1_0 asapInterest, ASAP_1_0 prot
438438
System.out.println(b.toString());
439439
//>>>>>>>>>>>>>>>>>>>debug
440440

441-
this.sendChunks(peer, this.getChunkStorage(), protocol, workingEra, lastEra, os);
441+
this.sendChunks(this.owner, peer, this.getChunkStorage(), protocol, workingEra, lastEra, os);
442442
//<<<<<<<<<<<<<<<<<<debug
443443
b = new StringBuilder();
444444
b.append(this.getLogStart());
@@ -453,7 +453,7 @@ public void handleASAPInterest(ASAP_Interest_PDU_1_0 asapInterest, ASAP_1_0 prot
453453
System.out.println(this.getLogStart() + "send chunks received from: " + sender);
454454
ASAPChunkStorage incomingChunkStorage = this.getIncomingChunkStorage(sender);
455455

456-
this.sendChunks(peer, incomingChunkStorage, protocol, workingEra, lastEra, os);
456+
this.sendChunks(sender, peer, incomingChunkStorage, protocol, workingEra, lastEra, os);
457457
}
458458
}
459459
}
@@ -467,7 +467,7 @@ public void setSendReceivedChunks(boolean on) throws IOException {
467467
this.saveStatus();
468468
}
469469

470-
private void sendChunks(String peer, ASAPChunkStorage chunkStorage,
470+
private void sendChunks(CharSequence sender, String recipient, ASAPChunkStorage chunkStorage,
471471
ASAP_1_0 protocol, int workingEra,
472472
int lastEra, OutputStream os) throws IOException, ASAPException {
473473
/*
@@ -509,7 +509,7 @@ private void sendChunks(String peer, ASAPChunkStorage chunkStorage,
509509
if (!this.isPublic(chunk)) {
510510
List<CharSequence> recipients = chunk.getRecipients();
511511

512-
if (!recipients.contains(peer)) {
512+
if (!recipients.contains(recipient)) {
513513
continue;
514514
}
515515
}
@@ -522,13 +522,13 @@ private void sendChunks(String peer, ASAPChunkStorage chunkStorage,
522522
//>>>>>>>>>>>>>>>>>>>debug
523523

524524
/*
525-
void assimilate(CharSequence peer, CharSequence recipientPeer, CharSequence format, CharSequence channel, int era,
525+
void assimilate(CharSequence recipient, CharSequence recipientPeer, CharSequence format, CharSequence channel, int era,
526526
int length, List<Integer> offsets, InputStream dataIS, OutputStream os, boolean signed)
527527
throws IOException, ASAPException;
528528
*/
529529

530-
protocol.assimilate(this.owner, // peer
531-
peer, // recipient
530+
protocol.assimilate(sender, // recipient
531+
recipient, // recipient
532532
this.format,
533533
chunk.getUri(), // channel ok
534534
workingEra, // era ok
@@ -539,12 +539,12 @@ void assimilate(CharSequence peer, CharSequence recipientPeer, CharSequence form
539539
false);
540540

541541
// remember sent
542-
chunk.deliveredTo(peer);
542+
chunk.deliveredTo(recipient);
543543
//<<<<<<<<<<<<<<<<<<debug
544544
b = new StringBuilder();
545545
b.append(this.getLogStart());
546546
b.append("remembered delivered to ");
547-
b.append(peer);
547+
b.append(recipient);
548548
System.out.println(b.toString());
549549
//>>>>>>>>>>>>>>>>>>>debug
550550
// sent to all recipients
@@ -567,7 +567,7 @@ void assimilate(CharSequence peer, CharSequence recipientPeer, CharSequence form
567567
}
568568

569569
// remember that we are in sync until that era
570-
this.setLastSeen(peer, workingEra);
570+
this.setLastSeen(recipient, workingEra);
571571

572572
// make a breakpoint here
573573
if(this.memento != null) this.memento.save(this);

src/net/sharksystem/asap/protocol/ASAPPersistentConnection.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public ASAPPersistentConnection(InputStream is, OutputStream os, MultiASAPEngine
3636
}
3737

3838
private String getLogStart() {
39-
return this.getClass().getSimpleName() + "(connected to: " + this.remotePeer + "): ";
39+
return this.getClass().getSimpleName() + "(to: " + this.remotePeer + "): ";
4040
}
4141

4242
private void setRemotePeer(String remotePeerName) {
@@ -386,18 +386,18 @@ public void run() {
386386
engineSetting.engine.handleASAPOffer((ASAP_OfferPDU_1_0) asapPDU, protocol, os);
387387
break;
388388
case ASAP_1_0.ASSIMILATE_CMD:
389-
System.out.println("getLogStart() + ASAPPDUExecutor call handleASAPAssimilate");
389+
System.out.println(getLogStart() + "ASAPPDUExecutor call handleASAPAssimilate");
390390
engineSetting.engine.handleASAPAssimilate((ASAP_AssimilationPDU_1_0) asapPDU, protocol, is, os,
391391
engineSetting.listener);
392392
break;
393393

394394
default:
395-
System.err.println(
396-
this.getClass().getSimpleName() + ": " + "unknown ASAP command: " + asapPDU.getCommand());
395+
System.err.println(getLogStart() + ": " + "unknown ASAP command: " + asapPDU.getCommand());
397396
}
398397
}
399398
catch(IOException | ASAPException e) {
400-
System.err.println("Exception while processing ASAP PDU - close streams" + e.getLocalizedMessage());
399+
System.err.println(getLogStart()
400+
+ "Exception while processing ASAP PDU - close streams" + e.getLocalizedMessage());
401401
try {
402402
os.close(); // more important to close than input stream - do it first
403403
is.close();

test/net/sharksystem/asap/MultihopTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public void twoHops() throws IOException, ASAPException, InterruptedException {
7878
String rootFolder = ui.getEngineRootFolderByStorageName("Clara:twoHops");
7979
ASAPStorage clara = ASAPEngineFS.getExistingASAPEngineFS(rootFolder);
8080

81-
/* that asap message is from Bob even if it was created by Alice .. !!
82-
apps on top of asap could and should deal differently with ownership of messages.
81+
/* message was actually from Bob but originated from Alice. It is put
82+
into a incoming folder as it would have been directly received from Alice.
83+
Signatures would allow ensuring if origin was really who mediator claims to be.
8384
*/
84-
ASAPChunkStorage claraBob = clara.getIncomingChunkStorage("Bob");
85+
ASAPChunkStorage claraBob = clara.getIncomingChunkStorage("Alice");
8586

8687
// clara era was increased after connection terminated - message from bob is in era before current one
8788
int eraToLook = ASAPEngine.previousEra(clara.getEra());

0 commit comments

Comments
 (0)