diff --git a/examples/simple_key_value_store.rs b/examples/simple_key_value_store.rs index 0049ebe903..596f483c99 100644 --- a/examples/simple_key_value_store.rs +++ b/examples/simple_key_value_store.rs @@ -142,7 +142,7 @@ impl Node { from_authority : Authority, response_token : Option) { match request { - ExternalRequest::Get(data_request) => { + ExternalRequest::Get(data_request, _) => { self.handle_get_request(data_request, our_authority, from_authority, @@ -163,10 +163,10 @@ impl Node { } } - fn handle_get_request(&mut self, data_request : DataRequest, - our_authority : Authority, - from_authority : Authority, - response_token : Option) { + fn handle_get_request(&mut self, data_request: DataRequest, + our_authority: Authority, + from_authority: Authority, + response_token: Option) { let name = match data_request { DataRequest::PlainData(name) => name, _ => { println!("Node: Only serving plain data in this example"); return; } @@ -356,7 +356,7 @@ impl Client { }; } - fn send_get_request(&self, what: String) { + fn send_get_request(&mut self, what: String) { let name = Client::calculate_key_name(&what); self.routing_client.get_request(Authority::NaeManager(name.clone()), diff --git a/src/authority.rs b/src/authority.rs index 9ab4965e3f..601a7f5b03 100644 --- a/src/authority.rs +++ b/src/authority.rs @@ -123,7 +123,7 @@ pub fn our_authority(message: &RoutingMessage, routing_table: &RoutingTable) -> let element = match message.content { Content::ExternalRequest(ref request) => { match *request { - ExternalRequest::Get(ref data_request) => Some(data_request.name().clone()), + ExternalRequest::Get(ref data_request, _) => Some(data_request.name().clone()), ExternalRequest::Put(ref data) => Some(data.name()), ExternalRequest::Post(ref data) => Some(data.name()), ExternalRequest::Delete(ref data) => Some(data.name()), diff --git a/src/messages.rs b/src/messages.rs index d83c0bb059..d51a3aa49f 100644 --- a/src/messages.rs +++ b/src/messages.rs @@ -67,7 +67,7 @@ impl Debug for SignedToken { /// These are the messageTypes routing provides #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug, RustcEncodable, RustcDecodable)] pub enum ExternalRequest { - Get(DataRequest), + Get(DataRequest, u8), Put(Data), Post(Data), Delete(Data), diff --git a/src/routing.rs b/src/routing.rs index 0e11c0d87d..32ef234d53 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -74,7 +74,7 @@ impl Routing { data_request: DataRequest) { let _ = self.action_sender.send(Action::SendContent( our_authority, location, - Content::ExternalRequest(ExternalRequest::Get(data_request)))); + Content::ExternalRequest(ExternalRequest::Get(data_request, 0u8)))); } /// Add something to the network diff --git a/src/routing_client.rs b/src/routing_client.rs index 363070d81f..e17be4b9bf 100644 --- a/src/routing_client.rs +++ b/src/routing_client.rs @@ -35,13 +35,13 @@ use messages::{ExternalRequest, ExternalResponse, InternalRequest, Content}; type RoutingResult = Result<(), RoutingError>; -/// Routing provides an actionable interface to RoutingNode. -/// On constructing a new Routing object a RoutingNode will also be started. -/// Routing objects are clonable for multithreading, or a Routing object can be -/// cloned with a new set of keys while preserving a single RoutingNode. +/// Routing provides an actionable interface to RoutingNode. On constructing a new Routing object a +/// RoutingNode will also be started. Routing objects are clonable for multithreading, or a Routing +/// object can be cloned with a new set of keys while preserving a single RoutingNode. #[derive(Clone)] pub struct RoutingClient { action_sender: mpsc::Sender, + get_counter: u8, } impl RoutingClient { @@ -67,14 +67,16 @@ impl RoutingClient { debug!("Routing node terminated running."); }); - RoutingClient { action_sender: action_sender } + RoutingClient { action_sender: action_sender, get_counter: 0u8 } } /// Send a Get message with a DataRequest to an Authority, signed with given keys. - pub fn get_request(&self, location: Authority, data_request: DataRequest) { + pub fn get_request(&mut self, location: Authority, data_request: DataRequest) { + self.get_counter = self.get_counter.wrapping_add(1); let _ = self.action_sender.send(Action::ClientSendContent( location, - Content::ExternalRequest(ExternalRequest::Get(data_request)))); + Content::ExternalRequest( + ExternalRequest::Get(data_request, self.get_counter)))); } /// Add something to the network diff --git a/src/routing_node.rs b/src/routing_node.rs index 68e2c53d86..66fe0f5640 100644 --- a/src/routing_node.rs +++ b/src/routing_node.rs @@ -1125,7 +1125,7 @@ impl RoutingNode { fn handle_cache_get(&mut self, request: ExternalRequest) -> Option { match request { - ExternalRequest::Get(data_request) => { + ExternalRequest::Get(data_request, _) => { match data_request { DataRequest::StructuredData(data_name, value) => { match self.structured_data_cache.as_mut() { @@ -1259,7 +1259,7 @@ mod test { immutable.get_type_tag().clone()); let response = ExternalResponse::Get(immutable_data, data_request.clone(), Some(sign_token)); - let request = ExternalRequest::Get(data_request); + let request = ExternalRequest::Get(data_request, 0u8); assert!(node.handle_cache_get(request.clone()).is_none()); node.handle_cache_put(response);