Exemplo n.º 1
0
 /**
  * Id (Version 0) +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 160 Bit + +
  * + + + + + + + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
  * @param buf
  * @throws IOException
  */
 public static Id build(rice.p2p.commonapi.rawserialization.InputBuffer buf) throws IOException {
   int[] material = new int[nlen];
   for (int i = 0; i < material.length; i++) {
     material[i] = buf.readInt();
   }
   return build(material);
 }
 public boolean loadCheckpoint(InputBuffer buffer) throws IOException {
   if (buffer.readInt() != 31173) throw new RuntimeException("invalid checkpoint");
   nextSendTime = buffer.readLong();
   if (buffer.readBoolean()) {
     dest = new HandleSerializer().deserialize(buffer);
   }
   if (logger.level <= Logger.FINER) logger.log("loadCheckpoint " + nextSendTime);
   byte[] bytes = new byte[buffer.readInt()];
   buffer.read(bytes);
   ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
   try {
     rand = (Random) new ObjectInputStream(bais).readObject();
   } catch (ClassNotFoundException cnfe) {
     IOException ioe = new IOException("Error reading random number from checkpoint");
     ioe.initCause(cnfe);
     throw ioe;
   }
   if (nextSendTime > 0) {
     scheduleMessageToBeSent(nextSendTime, true);
   }
   return true;
 }
 public static IdImpl build(InputBuffer buf) throws IOException {
   return new IdImpl(buf.readInt());
 }