Skip to content

Commit 50285cf

Browse files
committed
asap hop list is now parameter of notify method - and it works.
1 parent d67691c commit 50285cf

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

src/net/sharksystem/asap/ASAPPeerFS.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,25 @@ public void chunkReceived(String format, String senderE2E, String uri, int era,
2929
List<ASAPHop> asapHopList) throws IOException {
3030

3131
StringBuilder sb = new StringBuilder();
32+
String hopListString = "hoplist == null";
33+
if(asapHopList != null) {
34+
int i = 0;
35+
for (ASAPHop hop : asapHopList) {
36+
sb.append("hop#");
37+
sb.append(i++);
38+
sb.append(": ");
39+
sb.append(hop.toString());
40+
sb.append("\n");
41+
}
42+
hopListString = sb.toString();
43+
}
44+
45+
sb = new StringBuilder();
3246
sb.append("\n++++++++++++++++++++++++++++++++++++++++++ chunkReceived +++++++++++++++++++++++++++++++++++++++++++\n");
3347
sb.append("E2E|P2P: " + senderE2E + " | " + asapHopList.get(asapHopList.size()-1).sender() + " | uri: " + uri + " | era: " + era + " | appFormat: " + format);
34-
sb.append("\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
48+
sb.append("\n");
49+
sb.append(hopListString);
50+
sb.append("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
3551
this.log(sb.toString());
3652

3753
if(this.chunkReceivedListener != null) {

src/net/sharksystem/asap/engine/ASAPEngine.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,9 @@ public void handleASAPAssimilate(ASAP_AssimilationPDU_1_0 asapAssimilationPDU, A
403403

404404
// debug break
405405
//Log.writeLog(this, "!!!!!!!!!!!!!!!!!!!!!!!! ASSIMILATE PDU senderE2E: " + senderE2E);
406-
/*
407406
if(PeerIDHelper.sameID(senderE2E, "Alice_42")) {
408407
int i = 42;
409408
}
410-
*/
411409

412410
if(PeerIDHelper.sameID(senderE2E, this.owner)) {
413411
Log.writeLogErr(this, "I was offered messages from myself ("
@@ -629,6 +627,12 @@ public void handleASAPInterest(ASAP_Interest_PDU_1_0 asapInterest, ASAP_1_0 prot
629627
lastSeenEra = this.getOldestEra();
630628
}
631629

630+
/*
631+
if(PeerIDHelper.sameID(encounteredPeer, "Clara_44")) {
632+
int i = 42; // debug break;
633+
}
634+
*/
635+
632636
int workingEra = lastSeenEra;
633637
System.out.println(this.getLogStart() + "last_seen: " + workingEra + " | era: " + this.era);
634638

src/net/sharksystem/asap/engine/ASAPInMemoMessages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public byte[] getMessage(int position, boolean chronologically)
162162
}
163163

164164
if(this.messageCache != null && position >= this.firstIndexMessageCache && position <= this.lastIndexMessageCache) {
165-
return this.messageCache.get(position - this.firstIndexMessageCache); // TODO calculation correct?
165+
return this.messageCache.get(position - this.firstIndexMessageCache);
166166
}
167167

168168
// not yet in cache - find chunk with required message

src/net/sharksystem/asap/engine/ASAPInternalChunk.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,5 @@ public interface ASAPInternalChunk extends ASAPChunk {
8787

8888
List<ASAPHop> getASAPHopList();
8989

90-
void setASAPHopList(List<ASAPHop> asapHopList);
90+
void setASAPHopList(List<ASAPHop> asapHopList) throws IOException;
9191
}

src/net/sharksystem/asap/engine/ASAPInternalChunkFS.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ public List<ASAPHop> getASAPHopList() {
5656
return this.hopList;
5757
}
5858

59-
public void setASAPHopList(List<ASAPHop> asapHopList) {
59+
public void setASAPHopList(List<ASAPHop> asapHopList) throws IOException {
6060
this.hopList = asapHopList;
61+
this.saveStatus();
6162
}
6263

6364
public HashMap<String, String> getExtraData() {

test/net/sharksystem/CountsReceivedMessagesListener.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,6 @@ public void asapMessagesReceived(ASAPMessages messages,
2929
System.out.print(peerName);
3030
}
3131

32-
StringBuilder sb = new StringBuilder();
33-
for(ASAPHop hop : asapHopsList) {
34-
sb.append(hop.toString());
35-
sb.append("\n");
36-
}
37-
38-
System.out.println("\n###############################################################################");
39-
System.out.println("messages received (" + format + " | " + uri + "). size == " + messages.size()
40-
+ "hops\n" + sb.toString());
41-
System.out.println("###############################################################################");
42-
4332
this.numberOfMessages++;
4433
}
4534
}

0 commit comments

Comments
 (0)