Skip to content

Commit d95cbef

Browse files
ElestriasMarkuu-s
authored andcommitted
client updates
Signed-off-by: elestrias <[email protected]>
1 parent 73a2c91 commit d95cbef

File tree

1 file changed

+111
-43
lines changed

1 file changed

+111
-43
lines changed

core/cli/node/client.hpp

Lines changed: 111 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
#include "storage/car/car.hpp"
88
#include "storage/ipld/memory_indexed_car.hpp"
99
#include "storage/unixfs/unixfs.hpp"
10-
#include "storage/ipld/memory_indexed_car.hpp"
1110

1211
namespace fc::cli::_node {
1312
using api::FileRef;
1413
using api::ImportRes;
1514
using api::RetrievalOrder;
16-
using primitives::address::Address;
17-
using proofs::padPiece;
1815
using ::fc::storage::car::makeCar;
1916
using ::fc::storage::unixfs::wrapFile;
20-
17+
using primitives::address::Address;
18+
using proofs::padPiece;
2119

2220
struct clientRetrieve {
2321
struct Args {
@@ -57,7 +55,10 @@ namespace fc::cli::_node {
5755
RetrievalOrder order{};
5856
auto data_cid{cliArgv<CID>(argv, 0, "dataCid")};
5957
auto path{cliArgv<boost::filesystem::path>(argv, 1, "path")};
60-
order.client = (args.from ? *args.from : cliTry(api._->WalletDefaultAddress(), "Getting address of default wallet..."));
58+
order.client =
59+
(args.from ? *args.from
60+
: cliTry(api._->WalletDefaultAddress(),
61+
"Getting address of default wallet..."));
6162
order.miner = (args.provider ? *args.provider : Address{});
6263
if (args.max_price) {
6364
fmt::print("max price is {}fil ({}attofil)\n",
@@ -75,25 +76,27 @@ namespace fc::cli::_node {
7576

7677
struct clientImportData {
7778
struct Args {
78-
CLI_BOOL("car", "import from a car file instead of a regular file")car;
79+
CLI_BOOL("car", "import from a car file instead of a regular file") car;
7980

8081
CLI_OPTS() {
81-
Opts opts;
82-
car(opts);
83-
return opts;
82+
Opts opts;
83+
car(opts);
84+
return opts;
8485
}
8586
};
8687

8788
CLI_RUN() {
8889
Node::Api api{argm};
8990
auto path{cliArgv<std::string>(argv, 0, "path to file to import")};
9091
FileRef file_ref{path, args.car};
91-
auto result = cliTry(api._->ClientImport(file_ref), "Processing data import");
92+
auto result =
93+
cliTry(api._->ClientImport(file_ref), "Processing data import");
9294
fmt::print("File Root CID: " + result.root.toString().value());
9395
fmt::print("Data Import Success");
9496
}
9597
};
9698

99+
<<<<<<< HEAD
97100

98101
<<<<<<< HEAD
99102
struct clientGenerateCar{
@@ -108,13 +111,18 @@ namespace fc::cli::_node {
108111
}
109112
=======
110113
struct Node_client_generateCar: Empty{
114+
=======
115+
struct Node_client_generateCar : Empty {
116+
>>>>>>> f1466404 (client updates)
111117
CLI_RUN() {
112118
auto path_to{cliArgv<boost::filesystem::path>(argv, 0, "input-path")};
113119
auto path_out{cliArgv<boost::filesystem::path>(argv, 1, "output-path")};
114120
>>>>>>> 172a64dc (client methods cli updates)
115121

116122
auto tmp_path = path_to.string() + ".unixfs-tmp.car";
117-
auto ipld = cliTry(MemoryIndexedCar::make(tmp_path, true), "Creting IPLD instance of {}", tmp_path);
123+
auto ipld = cliTry(MemoryIndexedCar::make(tmp_path, true),
124+
"Creting IPLD instance of {}",
125+
tmp_path);
118126
std::ifstream file{path_to.string()};
119127
auto root = cliTry(wrapFile(*ipld, file));
120128
cliTry(::fc::storage::car::makeSelectiveCar(
@@ -124,34 +132,50 @@ namespace fc::cli::_node {
124132
}
125133
};
126134

135+
<<<<<<< HEAD
127136
struct clientLocal: Empty{
128137
CLI_RUN(){
129138
Node::Api api {argm};
130139
CLI_TRY_TEXT(result, api._->ClientListImports(), "Fail of getting imports list");
131140
for(auto it = result.begin(); it != result.end(); it++){
141+
=======
142+
struct Node_client_local : Empty {
143+
CLI_RUN() {
144+
Node::Api api{argm};
145+
auto result = cliTry(api._->ClientListImports(), "Getting imports list");
146+
for (auto it = result.begin(); it != result.end(); it++) {
147+
>>>>>>> f1466404 (client updates)
132148
fmt::print("Root CID: {} \n", it->root.toString().value());
133149
fmt::print("Source: {}\n", it->source);
134150
fmt::print("Path: {}\n", it->path);
135151
}
136152
}
137153
};
138154

155+
<<<<<<< HEAD
139156
<<<<<<< HEAD
140157
struct clientFind{
141158
struct Args{
142159
=======
143160
struct Node_client_find{
161+
=======
162+
struct Node_client_find {};
163+
>>>>>>> f1466404 (client updates)
144164

145-
};
146-
147-
struct Node_client_listRetrieval{
165+
struct Node_client_listRetrieval {
148166
struct Args {
167+
<<<<<<< HEAD
149168
CLI_BOOL("verbose", "print verbose deal details")verbose;
150169
CLI_BOOL("show-failed", "show failed/failing deals")failed_show;
151170
CLI_BOOL("completed", "show completed retrievals")completed_show;
152171
>>>>>>> 172a64dc (client methods cli updates)
172+
=======
173+
CLI_BOOL("verbose", "print verbose deal details") verbose;
174+
CLI_BOOL("show-failed", "show failed/failing deals") failed_show;
175+
CLI_BOOL("completed", "show completed retrievals") completed_show;
176+
>>>>>>> f1466404 (client updates)
153177

154-
CLI_OPTS(){
178+
CLI_OPTS() {
155179
Opts opts;
156180
verbose(opts);
157181
failed_show(opts);
@@ -160,24 +184,24 @@ namespace fc::cli::_node {
160184
}
161185
};
162186

163-
CLI_RUN(){
187+
CLI_RUN() {
164188
Node::Api api{argm};
165189
bool failed_show = !args.failed_show;
166-
//TODO: continue;
190+
// TODO: continue;
167191
// chan = ()
168192
// if(flag){
169193
// chan->read([](){
170194
// print(api->stateRetrivalsDeals)
171195
//
172196
// })
173-
while(true){
174-
sleep(10000000000);
175-
}
197+
while (true) {
198+
sleep(10000000000);
199+
}
176200
//
177201
}
178-
179202
};
180203

204+
<<<<<<< HEAD
181205

182206

183207
<<<<<<< HEAD
@@ -269,6 +293,9 @@ namespace fc::cli::_node {
269293
>>>>>>> b414cb63 (example client)
270294
=======
271295
struct Node_client_inspectDeal{
296+
=======
297+
struct Node_client_inspectDeal {
298+
>>>>>>> f1466404 (client updates)
272299
struct Args {
273300
CLI_OPTIONAL("proposal-cid", "proposal cid of deal to be inspected", CID)
274301
proposal_cid;
@@ -280,79 +307,120 @@ namespace fc::cli::_node {
280307
return opts;
281308
}
282309
};
283-
CLI_RUN(){
310+
CLI_RUN() {
284311
Node::Api api{argm};
285-
286-
287-
288312
}
289-
290313
};
291-
struct Node_client_list_deals{
314+
struct Node_client_list_deals {
292315
struct Args {
293316
CLI_BOOL("show-failed", "show failed/failing deals") failed_show;
294-
CLI_OPTS(){
317+
CLI_OPTS() {
295318
Opts opts;
296319
failed_show(opts);
297320
return opts;
298321
}
299322
};
300323

301-
CLI_RUN(){
324+
CLI_RUN() {
302325
Node::Api api{argm};
303326
fmt::print("Not supported yet\n");
304-
auto local_deals = cliTry(api._->ClientListDeals(), "Getting local client deals...");
327+
auto local_deals =
328+
cliTry(api._->ClientListDeals(), "Getting local client deals...");
305329
// TODO(Markuus): make output;
306330
}
307331
};
308332

309-
struct Node_client_balances{
310-
struct Args{
311-
CLI_OPTIONAL("client", "specifies market client", Address)client;
312-
CLI_OPTS(){
313-
Opts opts;
333+
struct Node_client_balances {
334+
struct Args {
335+
CLI_OPTIONAL("client", "specifies market client", Address) client;
336+
CLI_OPTS() {
337+
Opts opts;
314338
client(opts);
315339
return opts;
316340
}
317341
};
318342

319-
CLI_RUN(){
343+
CLI_RUN() {
320344
Node::Api api{argm};
321-
Address addr = (args.client ? *args.client : cliTry(api._->WalletDefaultAddress(), "Getting address of default wallet..."));
345+
Address addr =
346+
(args.client ? *args.client
347+
: cliTry(api._->WalletDefaultAddress(),
348+
"Getting address of default wallet..."));
322349
auto balance = cliTry(api._->StateMarketBalance(addr, TipsetKey()));
323350

324-
325351
fmt::print(" Escrowed Funds: {}\n", AttoFil{balance.escrow});
326352
fmt::print(" Locked Funds: {}\n", AttoFil{balance.locked});
327-
//TODO: Reserved and Avaliable
353+
// TODO: Reserved and Avaliable
328354
}
329355
};
330356

357+
<<<<<<< HEAD
331358

332359
<<<<<<< HEAD
333360
>>>>>>> 172a64dc (client methods cli updates)
334361
=======
335362
struct Node_client_getDeal: Empty{
336363
CLI_RUN(){
364+
=======
365+
struct Node_client_getDeal : Empty {
366+
CLI_RUN() {
367+
>>>>>>> f1466404 (client updates)
337368
Node::Api api{argm};
338369
auto proposal_cid{cliArgv<CID>(argv, 0, "proposal cid of deal to get")};
339370
// TODO: Client getDealInfo
340371
}
341372
};
342373

343-
struct Node_client_stat: Empty{
374+
struct Node_client_stat : Empty {
344375
CLI_RUN() {
345376
Node::Api api{argm};
346377
auto cid{cliArgv<CID>(argv, 0, " cid of localy stored file")};
347-
//auto deal_size = cliTry(api._->);
348-
//TODO: CLientDealSize;
378+
// auto deal_size = cliTry(api._->);
379+
// TODO: CLientDealSize;
349380
}
350-
351381
};
352382

383+
struct Node_client_listTransfers {
384+
struct Args {
385+
CLI_BOOL("completed", "show completed data transfers") completed;
386+
CLI_BOOL("watch",
387+
"watch deal updates in real-time, rather than a one time list")
388+
watch;
389+
CLI_BOOL("show-failed", "show failed/cancelled transfers") failed_show;
353390

391+
CLI_OPTS() {
392+
Opts opts;
393+
completed(opts);
394+
watch(opts);
395+
failed_show(opts);
396+
return opts;
397+
}
398+
};
354399

400+
CLI_RUN() {
401+
fmt::print("Not supported yet");
402+
// TODO: ClientListDataTransfers
403+
}
404+
};
405+
406+
struct Node_client_grantDatacap {
407+
struct Args {
408+
CLI_OPTIONAL("from",
409+
"specifies the adrress of notary to send message from",
410+
Address)
411+
from;
412+
CLI_OPTS() {
413+
Opts opts;
414+
from(opts);
415+
return opts;
416+
}
417+
};
355418

419+
CLI_RUN() {
420+
auto target{cliArgv<Address>(argv, 0, "target address")};
421+
auto allowness{cliArgv<AttoFil>(argv, 1, "amount")};
422+
}
423+
};
356424

357425
>>>>>>> 490821f3 (client updates)
358426
} // namespace fc::cli::_node

0 commit comments

Comments
 (0)