@Override public short definitelyWantKey(Key key, byte[] saltedKey, ClientContext context) { if(!key.equals(this.key)) return -1; else return prio; }
@Override public SendableGet[] getRequestsForKey(Key key, byte[] saltedKey, ClientContext context) { if(!key.equals(this.key)) return null; return new SendableGet[] { fetcher }; }
@Override public boolean probablyWantKey(Key key, byte[] saltedKey) { if(done) return false; return key.equals(this.key); }
@Override public void snoop(Message m, Node n) { if(((!isSSK) && m.getSpec() == DMT.FNPCHKDataRequest) || (isSSK && m.getSpec() == DMT.FNPSSKDataRequest)) { Key key = (Key) m.getObject(DMT.FREENET_ROUTING_KEY); if(key.equals(nodeKey)) { visited[n.getDarknetPortNumber() - DARKNET_PORT_BASE] = true; } } }
@Override public boolean handleBlock(Key key, byte[] saltedKey, KeyBlock found, ClientContext context) { if(!key.equals(this.key)) return false; try { fetcher.onGotKey(key, found, context); } catch (Throwable t) { Logger.error(this, "Failed: "+t, t); fetcher.onFailure(new LowLevelGetException(LowLevelGetException.INTERNAL_ERROR), null, context); } synchronized(this) { done = true; } return true; }
public void onGotKey(Key key, KeyBlock block, ClientContext context) { synchronized(this) { if(finished) { if(logMINOR) Logger.minor(this, "onGotKey() called twice on "+this, new Exception("debug")); return; } finished = true; if(isCancelled()) return; if(key == null) throw new NullPointerException(); if(this.key == null) throw new NullPointerException("Key is null on "+this); if(!key.equals(this.key.getNodeKey(false))) { Logger.normal(this, "Got sent key "+key+" but want "+this.key+" for "+this); return; } } unregister(context, getPriorityClass()); // Key has already been removed from pendingKeys onSuccess(block, false, null, context); }