public static void varString(String value, OutputStream out) throws IOException { byte[] bytes = value.getBytes("utf-8"); // Technically, it says the length in characters, but I think this one might be correct. // It doesn't really matter, as only ASCII characters are being used. // see also Decode#varString() varInt(bytes.length, out); out.write(bytes); }
public static void varString(String value, OutputStream stream) throws IOException { byte[] bytes = value.getBytes("utf-8"); // FIXME: technically, it says the length in characters, but I think this one might be correct // see also Decode#varString() varInt(bytes.length, stream); stream.write(bytes); }
public static byte[] calculateTag(long version, long stream, byte[] ripe) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); Encode.varInt(version, out); Encode.varInt(stream, out); out.write(ripe); return Arrays.copyOfRange(Security.doubleSha512(out.toByteArray()), 32, 64); } catch (IOException e) { throw new RuntimeException(e); } }
public static byte[] varInt(long value) { ByteBuffer buffer = ByteBuffer.allocate(9); varInt(value, buffer); buffer.flip(); return Bytes.truncate(buffer.array(), buffer.limit()); }
@Override public void write(OutputStream out) throws IOException { Encode.varInt(addresses.size(), out); for (NetworkAddress address : addresses) { address.write(out); } }
@Override public void write(ByteBuffer buffer) { Encode.varInt(addresses.size(), buffer); for (NetworkAddress address : addresses) { address.write(buffer); } }
@Override public void write(OutputStream stream) throws IOException { Encode.varInt(addresses.size(), stream); for (NetworkAddress address : addresses) { address.write(stream); } }
@Override public void write(OutputStream stream) throws IOException { Encode.varInt(inventory.size(), stream); for (InventoryVector iv : inventory) { iv.write(stream); } }
@Override public void write(OutputStream out) throws IOException { Encode.varInt(inventory.size(), out); for (InventoryVector iv : inventory) { iv.write(out); } }
@Override public void write(ByteBuffer buffer) { Encode.varInt(inventory.size(), buffer); for (InventoryVector iv : inventory) { iv.write(buffer); } }
@Override public void write(OutputStream out) throws IOException { writeBytesToSign(out); Encode.varInt(signature.length, out); out.write(signature); }
@Override public void write(OutputStream stream) throws IOException { Encode.varInt(inventory.size(), stream); for (InventoryVector iv : inventory) { iv.write(stream); } }
@Override public void write(ByteBuffer buffer) { Encode.varInt(inventory.size(), buffer); for (InventoryVector iv : inventory) { iv.write(buffer); } }
public static byte[] calculateTag(long version, long stream, byte[] ripe) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); Encode.varInt(version, out); Encode.varInt(stream, out); out.write(ripe); return Arrays.copyOfRange(cryptography().doubleSha512(out.toByteArray()), 32, 64); } catch (IOException e) { throw new ApplicationException(e); } }