aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/gnunet/peerstore/IterateRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/gnunet/peerstore/IterateRequest.java')
-rw-r--r--src/main/java/org/gnunet/peerstore/IterateRequest.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/main/java/org/gnunet/peerstore/IterateRequest.java b/src/main/java/org/gnunet/peerstore/IterateRequest.java
new file mode 100644
index 0000000..ec7f7df
--- /dev/null
+++ b/src/main/java/org/gnunet/peerstore/IterateRequest.java
@@ -0,0 +1,72 @@
1/*
2 This file is part of GNUnet.
3 (C) 2011, 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20
21package org.gnunet.peerstore;
22
23import org.gnunet.mq.Envelope;
24import org.gnunet.peerstore.messages.IterateMessage;
25import org.gnunet.requests.Request;
26import org.gnunet.util.AbsoluteTimeMessage;
27import org.gnunet.util.PeerIdentity;
28
29class IterateRequest extends Request {
30 private final String sub_system;
31 private final PeerIdentity peer;
32 private final String key;
33 public final PeerstoreReceiver receiver;
34
35 public IterateRequest(String sub_system, PeerIdentity peer, String key,
36 PeerstoreReceiver receiver) {
37 this.sub_system = sub_system;
38 this.peer = peer;
39 this.key = key;
40 this.receiver = receiver;
41 }
42
43 @Override
44 public Envelope assembleRequest() {
45 IterateMessage im = new IterateMessage();
46 im.sub_system_size = this.sub_system.length() + 1;
47 im.sub_system = this.sub_system;
48 if (null == this.peer) {
49 im.peer_set = 0;
50 im.peer = new PeerIdentity();
51 } else {
52 im.peer_set = 1;
53 im.peer = peer;
54 }
55 if (null == this.key) {
56 im.key = null;
57 im.key_size = 0;
58 } else {
59 im.key_size = this.key.length() + 1;
60 im.key = this.key;
61 }
62 im.value_size = 0;
63 im.value = new byte[0];
64 im.expiry = new AbsoluteTimeMessage();
65 im.options = 0;
66 return new Envelope(im);
67 }
68
69 public void cancel() {
70 }
71
72}