Permalink
Browse files

discard feeds received out of sequence

  • Loading branch information...
1 parent a7c9793 commit 432c6c13ab1a2f1ce0a13323b564dff0392febae mic committed Feb 23, 2013
Showing with 10 additions and 6 deletions.
  1. +10 −6 blogracy-web/src/main/java/net/blogracy/controller/DistributedHashTable.java
View
16 blogracy-web/src/main/java/net/blogracy/controller/DistributedHashTable.java
@@ -205,12 +205,16 @@ public JSONObject getRecord(String user) {
public void putRecord(JSONObject record) {
try {
- String id = record.getString("id");
- JSONObject old = records.get(id);
- if (old != null) {
- String prev = old.getString("uri");
- record.put("prev", prev);
- }
+ String id = record.getString("id");
+ JSONObject old = records.get(id);
+ if (old != null) {
+ if (record.getString("version")
+ .compareTo(old.getString("version")) < 0) {
+ return;
+ }
+ String prev = old.getString("uri");
+ record.put("prev", prev);
+ }
records.put(id, record);
} catch (JSONException e1) {
e1.printStackTrace();

0 comments on commit 432c6c1

Please sign in to comment.