Package freenet.support.api

Examples of freenet.support.api.RandomAccessBuffer


   * @return True if we handled the message (i.e. always).
   */
  public boolean handleRequestRevocation(Message m, final PeerNode source) {
    // Do we have the data?

    final RandomAccessBuffer data = updateManager.revocationChecker.getBlobBuffer();

    if(data == null) {
      Logger.normal(this, "Peer " + source + " asked us for the blob file for the revocation key but we don't have it!");
      // Probably a race condition on reconnect, hopefully we'll be asked again
      return true;
    }

    final long uid = m.getLong(DMT.UID);

    final PartiallyReceivedBulk prb;
    long length;
    length = data.size();
    prb = new PartiallyReceivedBulk(updateManager.node.getUSM(), length,
            Node.PACKET_SIZE, data, true);

    final BulkTransmitter bt;
    try {
      bt = new BulkTransmitter(prb, source, uid, false, updateManager.ctr, true);
    } catch(DisconnectedException e) {
      Logger.error(this, "Peer " + source + " asked us for the blob file for the revocation key, then disconnected: " + e, e);
      data.close();
      return true;
    }

    final Runnable r = new Runnable() {

      @Override
      public void run() {
        try {
          if(!bt.send())
            Logger.error(this, "Failed to send revocation key blob to " + source.userToString() + " : " + bt.getCancelReason());
          else
            Logger.normal(this, "Sent revocation key blob to " + source.userToString());
        } catch (DisconnectedException e) {
          // Not much we can do here either.
          Logger.warning(this, "Failed to send revocation key blob (disconnected) to " + source.userToString() + " : " + bt.getCancelReason());
        } finally {
          data.close();
        }
      }
    };

    Message msg = DMT.createUOMSendingRevocation(uid, length, updateManager.getRevocationURI().toString());
View Full Code Here

TOP

Related Classes of freenet.support.api.RandomAccessBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.