MCPcopy Create free account
hub / github.com/BitVM/BitVM / new

Method new

bridge/src/client/data_store/sftp.rs:40–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

38
39impl Sftp {
40 pub async fn new() -> Option<Self> {
41 dotenv::dotenv().ok();
42 let host = dotenv::var("BRIDGE_SFTP_HOST");
43 let port = dotenv::var("BRIDGE_SFTP_PORT");
44 let username = dotenv::var("BRIDGE_SFTP_USERNAME");
45 // let keyfile_path = dotenv::var("BRIDGE_SFTP_KEYFILE_PATH");
46 let base_path = dotenv::var("BRIDGE_SFTP_BASE_PATH");
47
48 if host.is_err()
49 || port.is_err()
50 || username.is_err()
51 // || keyfile_path.is_err()
52 || base_path.is_err()
53 {
54 return None;
55 }
56
57 let credentials = SftpCredentials {
58 host: host.unwrap(),
59 port: port.unwrap(),
60 username: username.unwrap(),
61 // keyfile_path: keyfile_path.unwrap(),
62 base_path: base_path.unwrap(),
63 };
64
65 match test_connection(&credentials).await {
66 Ok(_) => Some(Self { credentials }),
67 Err(err) => {
68 eprintln!("{err:?}");
69 None
70 }
71 }
72 }
73
74 async fn get_object(&self, key: &str, file_path: Option<&str>) -> Result<Vec<u8>, String> {
75 let mut buffer: Vec<u8> = vec![];

Callers

nothing calls this directly

Calls 1

test_connectionFunction · 0.70

Tested by

no test coverage detected