changeset 613:5c2b0d47bb83 rust

Response has epoch_tag and params
author Matt Johnston <matt@ucc.asn.au>
date Thu, 02 Mar 2017 00:06:20 +0800
parents 5fc41e0833b4
children e1bab5b36352
files rust/src/paramwaiter.rs
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rust/src/paramwaiter.rs	Thu Mar 02 00:06:03 2017 +0800
+++ b/rust/src/paramwaiter.rs	Thu Mar 02 00:06:20 2017 +0800
@@ -9,6 +9,7 @@
 use std::rc::Rc;
 use std::sync::{Arc,Mutex};
 use std::error::Error;
+use std::cell::Cell;
 
 use tokio_core::reactor::Interval;
 use tokio_core::reactor::Handle;
@@ -19,6 +20,12 @@
 use types::*;
 use ::Config;
 
+#[derive(Deserialize, Debug)]
+struct Response {
+    epoch_tag: String,
+    params: Params,
+}
+
 #[derive(Clone)]
 pub struct ParamWaiter {
     limitlog: NotTooOften,
@@ -54,7 +61,13 @@
         let text = String::from_utf8_lossy(buf).to_string();
         let resp = req.response_code()?;
         match resp {
-            200 => Ok(Some(serde_json::from_str(&text)?)), // new params
+            200 => {
+                // new params
+                let r: Response = serde_json::from_str(&text)?;
+                // XXX
+                //self.epoch_tag = r.epoch_tag;
+                Ok(Some(r.params))
+            }
             304 => Ok(None), // unmodified (long polling timeout at the server)
             _ => {
                 Err(TemplogError::new(&format!("Wrong server response code {}: {}", resp, text)))