public static CHKBlock construct(byte[] data, byte[] header, byte cryptoAlgorithm) throws CHKVerifyException { return new CHKBlock(data, header, null, true, cryptoAlgorithm); }
/** * Construct from data retrieved, and a key. * Do not do full decode. Verify what can be verified without doing * a full decode. * @param key2 The client key. * @param header The header. * @param data The data. */ public ClientCHKBlock(byte[] data, byte[] header, ClientCHK key2, boolean verify) throws CHKVerifyException { block = new CHKBlock(data, header, key2.getNodeCHK(), verify, key2.cryptoAlgorithm); this.key = key2; }
private void verifyAndCommit(byte[] headers, byte[] data) throws KeyVerifyException { if(!isSSK) { CHKBlock block = new CHKBlock(data, headers, (NodeCHK)key); synchronized(this) { finalHeaders = headers; } if(logMINOR) Logger.minor(this, "Verified"); // Cache only in the cache, not the store. The reason for this is that // requests don't go to the full distance, and therefore pollute the // store; simulations it is best to only include data from requests // which go all the way i.e. inserts. node.storeShallow(block, canWriteClientCache, canWriteDatastore, tryOffersOnly); if(node.random.nextInt(RANDOM_REINSERT_INTERVAL) == 0) node.queueRandomReinsert(block); } else /*if (key instanceof NodeSSK)*/ { synchronized(this) { finalHeaders = headers; finalSskData = data; } try { SSKBlock block = new SSKBlock(data, headers, (NodeSSK)key, false); if(logMINOR) Logger.minor(this, "Verified SSK"); node.storeShallow(block, canWriteClientCache, canWriteDatastore, tryOffersOnly); } catch (KeyCollisionException e) { Logger.normal(this, "Collision on "+this); } } }
if(!canCommit) return null; if(!prb.allReceived()) return null; block = new CHKBlock(prb.getBlock(), headers, key); } catch (CHKVerifyException e) { Logger.error(this, "Verify failed in CHKInsertHandler: "+e+" - headers: "+HexUtil.bytesToHex(headers), e);
else { new CHKBlock(prb.getBlock(), headers, (NodeCHK) key); Logger.error(this,