Esempio n. 1
0
 /* (non-Javadoc)
  * @see java.lang.Runnable#run()
  */
 public void run() {
   byte[] bytesRead = null;
   int count = 0;
   while (true) {
     netQueue.hasAnyNetWork();
     bytesRead = netQueue.getWorkRR(Role.CLIENT);
     if (bytesRead != null) {
       Debug.profileStart("CLIENT_BYTES");
       protocolHandler.handle(bytesRead);
       Debug.profileFinis("CLIENT_BYTES");
       bytesRead = null;
       // continue;
     }
   }
 }
Esempio n. 2
0
  public RequestBatch(byte[] bytes, int count) {
    entries = new RequestCore[count];
    int offset = 0;
    int num = 0;

    while (num < count) {
      byte[] tmp = new byte[4];
      tmp[0] = bytes[offset + 2];
      tmp[1] = bytes[offset + 3];
      tmp[2] = bytes[offset + 4];
      tmp[3] = bytes[offset + 5];
      int size = (int) UnsignedTypes.bytesToLong(tmp);
      tmp = new byte[2];
      tmp[0] = bytes[offset];
      tmp[1] = bytes[offset + 1];
      int tag = UnsignedTypes.bytesToInt(tmp);

      if (tag == MessageTags.SignedRequestCore)
        tmp =
            new byte
                [size
                    + SignedMessage.computeAuthenticationSize()
                    + VerifiedMessageBase.getOffset()];
      else {

        tmp =
            new byte
                [size
                    + MacSignatureMessage.computeAuthenticationSize(
                        BFT.Parameters.getFilterCount(), BFT.Parameters.getOrderCount())
                    + VerifiedMessageBase.getOffset()];
      }
      for (int i = 0; i < tmp.length; i++, offset++) {
        tmp[i] = bytes[offset];
      }
      if (tag == MessageTags.SignedRequestCore) entries[num++] = new SignedRequestCore(tmp);
      else if (tag == MessageTags.FilteredRequestCore)
        entries[num++] = new FilteredRequestCore(tmp);
    }
    if (bytes.length != offset) {
      System.out.println("offset: " + offset);
      System.out.println("bytes.lenth: " + bytes.length);
      Debug.kill(new RuntimeException("unimplemented"));
    }
    this.bytes = bytes;
  }