Skip to content

Commit dab34ca

Browse files
authored
Merge pull request oreoslabs#28 from iron-fish/cleanup-oreowallet-and-standardize
cleanup logging and conform to latest iron-fish/ironfish RPC
2 parents a9d0005 + 961d26b commit dab34ca

File tree

8 files changed

+16
-9
lines changed

8 files changed

+16
-9
lines changed

crates/dservice/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl Manager {
219219
false => {
220220
let worker = ServerWorker::new(tx.clone());
221221
worker_name = register.name;
222-
info!("new worker: {}", worker_name.clone());
222+
debug!("new worker: {}", worker_name.clone());
223223
let _ = worker_server.workers.write().await.insert(worker_name.clone(), worker);
224224
let data = worker_server.task_queue.write().await.pop();
225225
match data {

crates/dworker/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tokio::{
1717
time::sleep,
1818
};
1919
use tokio_util::codec::{FramedRead, FramedWrite};
20-
use tracing::{debug, error, info};
20+
use tracing::{debug, error};
2121

2222
pub async fn decrypt(worker_pool: Arc<ThreadPool>, request: DRequest) -> DResponse {
2323
let DRequest {
@@ -91,7 +91,7 @@ pub async fn handle_connection(
9191
stream: TcpStream,
9292
worker_name: String,
9393
) -> anyhow::Result<()> {
94-
info!("connected to scheduler");
94+
debug!("connected to scheduler");
9595
let (r, w) = split(stream);
9696
let mut socket_w_handler = FramedWrite::new(w, DMessageCodec::default());
9797
let mut socket_r_handler = FramedRead::new(r, DMessageCodec::default());
@@ -133,7 +133,7 @@ pub async fn handle_connection(
133133
while let Some(Ok(message)) = socket_r_handler.next().await {
134134
match message {
135135
DMessage::DRequest(request) => {
136-
info!("new task from scheduler: {}", request.id.clone());
136+
debug!("new task from scheduler: {}", request.id.clone());
137137
let response = decrypt(worker_pool.clone(), request).await;
138138
if let Err(e) = task_tx.send(DMessage::DResponse(response)).await {
139139
error!("failed to send response to write channel, {}", e);

crates/networking/src/rpc_abi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct RpcImportAccountRequest {
4747
pub outgoing_view_key: String,
4848
pub public_address: String,
4949
pub created_at: Option<BlockInfo>,
50+
pub spending_key: Option<String>,
5051
}
5152

5253
#[derive(Debug, Deserialize, Serialize)]
@@ -365,6 +366,7 @@ pub struct RpcGetBlockResponse {
365366
pub struct RpcGetBlocksRequest {
366367
pub start: u64,
367368
pub end: u64,
369+
pub serialized: bool,
368370
}
369371

370372
#[derive(Debug, Deserialize, Serialize)]

crates/networking/src/rpc_handler/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ impl RpcHandler {
193193
.agent
194194
.clone()
195195
.post(&path)
196-
.send_json(RpcGetBlocksRequest { start, end });
196+
.send_json(RpcGetBlocksRequest { start, end, serialized: true });
197197
handle_response(resp)
198198
}
199199

crates/networking/src/rpc_handler/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
44
mod handler;
55

66
pub use handler::*;
7+
use tracing::error;
78

89
#[derive(Clone, Debug, Deserialize, Serialize)]
910
pub struct RpcError {
@@ -22,7 +23,10 @@ impl TryFrom<RpcError> for OreoError {
2223
// Should never happen
2324
return Ok(OreoError::Duplicate("0x00".to_string()));
2425
}
25-
_ => Ok(OreoError::InternalRpcError),
26+
_ => {
27+
error!("Rpc error: {:?}", value);
28+
return Ok(OreoError::InternalRpcError(value.message));
29+
}
2630
}
2731
}
2832
}

crates/networking/src/web_abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl TransactionDetail {
9595
memo: Some(memo.into()),
9696
value: value.into(),
9797
}),
98-
None => Err(OreoError::InternalRpcError),
98+
None => Err(OreoError::InternalRpcError("No note found".into())),
9999
}
100100
}
101101
}

crates/oreo_errors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub enum OreoError {
2020
#[error("Internal db error")]
2121
DBError,
2222
#[error("Internal Ironfish rpc error")]
23-
InternalRpcError,
23+
InternalRpcError(String),
2424
#[error("The `{0}` spend circuit can not generate proof")]
2525
GenerateSpendProofFailed(u32),
2626
#[error("The `{0}` output circuit can not generate proof")]
@@ -53,7 +53,7 @@ impl IntoResponse for OreoError {
5353
OreoError::NoImported(_) => (StatusCode::from_u16(602).unwrap(), self.to_string()),
5454
OreoError::Scanning(_) => (StatusCode::from_u16(603).unwrap(), self.to_string()),
5555
OreoError::Syncing => (StatusCode::from_u16(604).unwrap(), self.to_string()),
56-
OreoError::InternalRpcError => (StatusCode::from_u16(605).unwrap(), self.to_string()),
56+
OreoError::InternalRpcError(_) => (StatusCode::from_u16(605).unwrap(), self.to_string()),
5757
OreoError::GenerateSpendProofFailed(_) => {
5858
(StatusCode::from_u16(606).unwrap(), self.to_string())
5959
}

crates/server/src/handlers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub async fn import_account_handler<T: DBHandler>(
4747
incoming_view_key: incoming_view_key.clone(),
4848
outgoing_view_key: outgoing_view_key.clone(),
4949
public_address: public_address.clone(),
50+
spending_key: None,
5051
version: ACCOUNT_VERSION,
5152
name: account_name.clone(),
5253
created_at,

0 commit comments

Comments
 (0)