@Override public String toString() { return "USKChecker for "+key.getURI()+" for "+cb; }
public synchronized FreenetURI getURINoEncode() { return resultingKey == null ? null : resultingKey.getURI(); }
block = ClientCHKBlock.encode(buf, false, false, (short)-1, buf.length, COMPRESSOR_TYPE.DEFAULT_COMPRESSORDESCRIPTOR, false); insertKey = fetchKey = block.getClientKey(); testKey = insertKey.getURI(); Logger.normal(RealNodeRequestInsertTest.class,"Insert Key: "+insertKey.getURI()); Logger.normal(RealNodeRequestInsertTest.class,"Fetch Key: "+fetchKey.getURI()); try { insertAttempts++;
thisKey = FreenetURI.EMPTY_CHK_URI; else thisKey = key.getURI(); if(origURI == null) throw new NullPointerException(); this.uri = persistent ? origURI.clone() : origURI;
return; if(logMINOR) Logger.minor(this, "Found DBR hint edition "+hint+" for "+this.fetcher.getKey(null).getURI()+" for "+USKFetcher.this); processDBRHint(hint, context, this);
protected ClientKeyBlock encode(ClientContext context, boolean calledByCB) throws InsertException { ClientKeyBlock block; boolean shouldSend; synchronized(this) { if(finished) return null; if(sourceData == null) { Logger.error(this, "Source data is null on "+this+" but not finished!"); return null; } block = innerEncode(context.random); shouldSend = (resultingKey == null); resultingKey = block.getClientKey(); } if(logMINOR) Logger.minor(this, "Encoded "+resultingKey.getURI()+" for "+this+" shouldSend="+shouldSend+" dontSendEncoded="+dontSendEncoded); if(shouldSend && !dontSendEncoded) cb.onEncode(block.getClientKey(), this, context); return block; }
block = ClientCHKBlock.encode(buf, false, false, (short)-1, buf.length, COMPRESSOR_TYPE.DEFAULT_COMPRESSORDESCRIPTOR, false); insertKey = fetchKey = block.getClientKey(); testKey = insertKey.getURI();
/** * Add a block to the binary blob. */ protected void addKeyToBinaryBlob(ClientKeyBlock block, ClientContext context) { if(binaryBlobWriter == null) return; synchronized(this) { if(finished) { if(logMINOR) Logger.minor(this, "Add key to binary blob for "+this+" but already finished"); return; } } if(logMINOR) Logger.minor(this, "Adding key "+block.getClientKey().getURI()+" to "+this, new Exception("debug")); try { binaryBlobWriter.addKey(block, context); } catch (IOException e) { Logger.error(this, "Failed to write key to binary blob stream: "+e, e); onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, "Failed to write key to binary blob stream: "+e), null, context); } catch (BinaryBlobAlreadyClosedException e) { Logger.error(this, "Failed to write key to binary blob stream (already closed??): "+e, e); onFailure(new FetchException(FetchExceptionMode.BUCKET_ERROR, "Failed to write key to binary blob stream (already closed??): "+e), null, context); } }
@Override public void onSuccess(ClientKeyBlock block, boolean fromStore, Object reqTokenIgnored, ClientContext context) { if(parent instanceof ClientGetter) ((ClientGetter)parent).addKeyToBinaryBlob(block, context); Bucket data = extract(block, context); if(data == null) return; // failed context.uskManager.checkUSK(key.getURI(), fromStore, block.isMetadata()); if(!block.isMetadata()) { onSuccess(new FetchResult(new ClientMetadata(null), data), context); } else { onFailure(new FetchException(FetchExceptionMode.INVALID_METADATA, "Metadata where expected data"), false, context); } }