Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for yagna tokio upgrade #119

Merged
merged 4 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ members = [
[dependencies]
ya-client-model = { version= "^0.4", path = "model" }

awc = "2.0"
actix-codec = "0.3"
bytes = "0.5"
awc = "3"
actix-codec = "0.5"
bytes = "1"
chrono = "0.4"
envy = "0.4"
futures = "0.3"
Expand All @@ -32,22 +32,22 @@ heck = "0.3.1"
log = "0.4"
rand = "0.6"
mime = "0.3"
serde = "1.0"
serde = "1"
serde_json = "1.0"
serde_qs = "0.8"
thiserror = "1.0"
url = "2.1"
thiserror = "1"
url = "2"

graphene-sgx = { version = "0.3.3", optional = true }
lazy_static = { version = "1.4", optional = true }
secp256k1 = { version = "0.19", optional = true }
structopt = { version = "0.3.12", optional = true }
structopt = { version = "0.3", optional = true }
openssl = { version = "0.10", optional = true }

[dev-dependencies]
actix-rt = "1.1"
actix-rt = "2.7.0"
anyhow = "1.0"
env_logger = "0.7"
env_logger = "0.9"
structopt = "0.3"

[package.metadata.release]
Expand Down
8 changes: 4 additions & 4 deletions model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ sgx = ['secp256k1', 'openssl', 'hex', 'secp256k1/serde']
[dependencies]
bigdecimal = { version = "0.2", features = ["serde"]}
chrono = { version = "0.4", features = ["serde"]}
derive_more = "0.99.11"
rand = "0.7.3"
serde = { version = "^1.0", features = ["derive"] }
serde_json = "^1.0"
derive_more = "0.99"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
strum = "0.19"
strum_macros = "0.19"
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion model/src/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pub use self::runtime_event::{RuntimeEvent, RuntimeEventKind};
#[cfg(feature = "sgx")]
pub use self::sgx_credentials::SgxCredentials;

pub const ACTIVITY_API_PATH: &str = "/activity-api/v1/";
pub const ACTIVITY_API_PATH: &str = "/activity-api/v1";
2 changes: 1 addition & 1 deletion model/src/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ pub use property_query::PropertyQuery;
pub use proposal::Proposal;
pub use reason::Reason;

pub const MARKET_API_PATH: &str = "market-api/v1/";
pub const MARKET_API_PATH: &str = "/market-api/v1";
2 changes: 1 addition & 1 deletion model/src/net.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

pub const NET_API_PATH: &str = "/net-api/v1/";
pub const NET_API_PATH: &str = "/net-api/v1";

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
2 changes: 1 addition & 1 deletion model/src/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ pub use self::payment::Payment;
pub use self::rejection::Rejection;
pub use self::rejection_reason::RejectionReason;

pub const PAYMENT_API_PATH: &str = "payment-api/v1/";
pub const PAYMENT_API_PATH: &str = "/payment-api/v1";
14 changes: 8 additions & 6 deletions src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
use actix_codec::Framed;
use awc::{
error::{PayloadError, SendRequestError},
http::{header, HeaderMap, HeaderName, HeaderValue, Method, StatusCode},
http::header::{HeaderMap, HeaderName, HeaderValue},
http::{header, Method, StatusCode},
ws::Codec,
BoxedSocket, ClientRequest, ClientResponse, SendClientRequest,
};
use bytes::{Buf, Bytes, BytesMut};
use bytes::{Bytes, BytesMut};
use futures::stream::Peekable;
use futures::{Stream, StreamExt, TryStreamExt};
use heck::MixedCase;
Expand Down Expand Up @@ -54,7 +55,8 @@ pub trait WebInterface {
if let Some(url) = std::env::var(Self::API_URL_ENV_VAR).ok() {
return Ok(Url::from_str(&url)?.into());
}
Ok(base_url.join(Self::API_SUFFIX)?.into())
let with_trailing = format!("{}/", Self::API_SUFFIX);
Ok(base_url.join(&with_trailing)?.into())
}

fn from_client(client: WebClient) -> Self;
Expand Down Expand Up @@ -117,7 +119,7 @@ impl WebClient {
let request = self
.awc
.request(method.clone(), &url)
.set(header::Accept(vec![header::qitem(mime::TEXT_EVENT_STREAM)]));
.insert_header((header::ACCEPT, mime::TEXT_EVENT_STREAM));
let stream = request
.send()
.await
Expand Down Expand Up @@ -319,7 +321,7 @@ impl WebClientBuilder {
}
}
for (key, value) in self.headers.iter() {
builder = builder.header(key.clone(), value.clone());
builder = builder.add_default_header((key.clone(), value.clone()));
}

WebClient {
Expand Down Expand Up @@ -446,7 +448,7 @@ where

fn next_event(&mut self, start_idx: usize) -> Option<Result<Event>> {
let idx = max(0, start_idx as i64 - 1) as usize;
if let Some(idx) = Self::find(self.buffer.bytes(), b"\n\n", idx) {
if let Some(idx) = Self::find(&self.buffer, b"\n\n", idx) {
let bytes = self.buffer.split_to(idx);
return String::from_utf8(bytes.to_vec())
.map(Event::try_from)
Expand Down