Diff
Not logged in

Differences From Artifact [5913e8b5ac]:

To Artifact [43851bc51d]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
..
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
117
118
119
120
121
122
123
124


125
126
127
128

129

130
131
132
133
134
135
136
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement, version 1.1.  This, along with the
// Licenses can be found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.
................................................................................

    /// Send a `Get` request to the network and return the data received in the response.
    ///
    /// This is a blocking call and will wait indefinitely for the response.
    pub fn get(&mut self, request: DataIdentifier) -> Option<Data> {
        let message_id = MessageId::new();
        unwrap!(self.routing_client
            .send_get_request(Authority::NaeManager(*request.name()),
                              request.clone(),
                              message_id));

        // Wait for Get success event from Routing
        loop {
            match recv_with_timeout(&self.receiver, Duration::from_secs(RESPONSE_TIMEOUT_SECS)) {
                Some(Event::Response { response: Response::GetSuccess(data, id), .. }) => {
                    if message_id != id {
                        error!("GetSuccess for {:?}, but with wrong message_id {:?} instead of \
................................................................................
                               data.name(),
                               id,
                               message_id);
                    }
                    return Some(data);
                }
                Some(Event::Response {
                    response: Response::GetFailure { external_error_indicator, .. },
                .. }) => {
                    error!("Failed to Get {:?}: {:?}",
                           request.name(),
                           unwrap!(String::from_utf8(external_error_indicator)));
                    return None;
                }
                Some(Event::Terminate) |
                Some(Event::RestartRequired) => self.disconnected(),
................................................................................
    ///
    /// This is a blocking call and will wait indefinitely for a `PutSuccess` or `PutFailure`
    /// response.
    pub fn put(&self, data: Data) -> Result<(), ()> {
        let data_id = data.identifier();
        let message_id = MessageId::new();
        unwrap!(self.routing_client
            .send_put_request(Authority::ClientManager(*self.name()), data, message_id));



        // Wait for Put success event from Routing
        loop {
            match recv_with_timeout(&self.receiver, Duration::from_secs(RESPONSE_TIMEOUT_SECS)) {

                Some(Event::Response { response: Response::PutSuccess(rec_data_id, id), .. }) => {

                    if message_id != id {
                        error!("Stored {:?}, but with wrong message_id {:?} instead of {:?}.",
                               data_id.name(),
                               id,
                               message_id);
                        return Err(());
                    } else if data_id == rec_data_id {







|
|







 







|
|
|







 







|
|







 







|
>
>




>
|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
..
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2015 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under (1) the MaidSafe.net Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
//
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
//
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
//
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.
................................................................................

    /// Send a `Get` request to the network and return the data received in the response.
    ///
    /// This is a blocking call and will wait indefinitely for the response.
    pub fn get(&mut self, request: DataIdentifier) -> Option<Data> {
        let message_id = MessageId::new();
        unwrap!(self.routing_client
                    .send_get_request(Authority::NaeManager(*request.name()),
                                      request.clone(),
                                      message_id));

        // Wait for Get success event from Routing
        loop {
            match recv_with_timeout(&self.receiver, Duration::from_secs(RESPONSE_TIMEOUT_SECS)) {
                Some(Event::Response { response: Response::GetSuccess(data, id), .. }) => {
                    if message_id != id {
                        error!("GetSuccess for {:?}, but with wrong message_id {:?} instead of \
................................................................................
                               data.name(),
                               id,
                               message_id);
                    }
                    return Some(data);
                }
                Some(Event::Response {
                         response: Response::GetFailure { external_error_indicator, .. }, ..
                     }) => {
                    error!("Failed to Get {:?}: {:?}",
                           request.name(),
                           unwrap!(String::from_utf8(external_error_indicator)));
                    return None;
                }
                Some(Event::Terminate) |
                Some(Event::RestartRequired) => self.disconnected(),
................................................................................
    ///
    /// This is a blocking call and will wait indefinitely for a `PutSuccess` or `PutFailure`
    /// response.
    pub fn put(&self, data: Data) -> Result<(), ()> {
        let data_id = data.identifier();
        let message_id = MessageId::new();
        unwrap!(self.routing_client
                    .send_put_request(Authority::ClientManager(*self.name()),
                                      data,
                                      message_id));

        // Wait for Put success event from Routing
        loop {
            match recv_with_timeout(&self.receiver, Duration::from_secs(RESPONSE_TIMEOUT_SECS)) {
                Some(Event::Response {
                         response: Response::PutSuccess(rec_data_id, id), ..
                     }) => {
                    if message_id != id {
                        error!("Stored {:?}, but with wrong message_id {:?} instead of {:?}.",
                               data_id.name(),
                               id,
                               message_id);
                        return Err(());
                    } else if data_id == rec_data_id {