Skip to content
Snippets Groups Projects

Write `get-file` and commands to get the list of blocks from another node

5 files
+ 100
7
Compare changes
  • Side-by-side
  • Inline

Files

+ 18
1
@@ -14,6 +14,7 @@ use tracing::{error, info};
use crate::app::AppState;
use crate::error::DragoonError;
use crate::peer_block_info::PeerBlockInfo;
use crate::to_serialize::{ConvertSer, JsonWrapper};
// use komodo::linalg::Matrix;
@@ -85,6 +86,11 @@ pub(crate) enum DragoonCommand {
block_hash: String,
sender: Sender<Vec<u8>>,
},
GetBlocksInfoFrom {
peer_id: PeerId,
file_hash: String,
sender: Sender<PeerBlockInfo>,
},
GetBlockList {
file_hash: String,
sender: Sender<Vec<String>>,
@@ -134,6 +140,7 @@ impl std::fmt::Display for DragoonCommand {
DragoonCommand::DragoonSend { .. } => write!(f, "dragoon-send"),
DragoonCommand::EncodeFile { .. } => write!(f, "encode-file"),
DragoonCommand::GetBlockFrom { .. } => write!(f, "get-block-from"),
DragoonCommand::GetBlocksInfoFrom { .. } => write!(f, "get-blocks-info-from"),
DragoonCommand::GetBlockList { .. } => write!(f, "get-block-list"),
DragoonCommand::GetConnectedPeers { .. } => write!(f, "get-connected-peers"),
DragoonCommand::GetFile { .. } => write!(f, "get-file"),
@@ -269,12 +276,22 @@ pub(crate) async fn create_cmd_get_block_from(
Path((peer_id_base_58, file_hash, block_hash)): Path<(String, String, String)>,
State(state): State<Arc<AppState>>,
) -> Response {
info!("running command `get_from_from`");
info!("running command `get_block_from`");
let bytes = bs58::decode(peer_id_base_58).into_vec().unwrap();
let peer_id = PeerId::from_bytes(&bytes).unwrap();
dragoon_command!(state, GetBlockFrom, peer_id, file_hash, block_hash)
}
pub(crate) async fn create_cmd_get_blocks_info_from(
Path((peer_id_base_58, file_hash)): Path<(String, String)>,
State(state): State<Arc<AppState>>,
) -> Response {
info!("running command `get_blocks_info_from`");
let bytes = bs58::decode(peer_id_base_58).into_vec().unwrap();
let peer_id = PeerId::from_bytes(&bytes).unwrap();
dragoon_command!(state, GetBlocksInfoFrom, peer_id, file_hash)
}
pub(crate) async fn create_cmd_get_block_list(
Path(file_hash): Path<String>,
State(state): State<Arc<AppState>>,
Loading