Пример #1
0
 @Override
 protected void peercoinSerializeToStream(OutputStream stream) throws IOException {
   if (protocolVersion >= 31402) {
     // TODO this appears to be dynamic because the client only ever sends out it's own address
     // so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
     // the address refers to this client.
     int secs = (int) (Utils.currentTimeSeconds());
     uint32ToByteStreamLE(secs, stream);
   }
   uint64ToByteStreamLE(services, stream); // nServices.
   // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it
   // by hand.
   byte[] ipBytes = addr.getAddress();
   if (ipBytes.length == 4) {
     byte[] v6addr = new byte[16];
     System.arraycopy(ipBytes, 0, v6addr, 12, 4);
     v6addr[10] = (byte) 0xFF;
     v6addr[11] = (byte) 0xFF;
     ipBytes = v6addr;
   }
   stream.write(ipBytes);
   // And write out the port. Unlike the rest of the protocol, address and port is in big endian
   // byte order.
   stream.write((byte) (0xFF & port >> 8));
   stream.write((byte) (0xFF & port));
 }
Пример #2
0
 static {
   try {
     INSTANCE = new MnemonicCode();
   } catch (FileNotFoundException e) {
     // We expect failure on Android. The developer has to set INSTANCE themselves.
     if (!Utils.isAndroidRuntime()) log.error("Could not find word list", e);
   } catch (IOException e) {
     log.error("Failed to load word list", e);
   }
 }