4
4
5
5
#pragma once
6
6
#include " cli/node/node.hpp"
7
+ #include " storage/car/car.hpp"
8
+ #include " storage/ipld/memory_indexed_car.hpp"
9
+ #include " storage/unixfs/unixfs.hpp"
10
+ #include " storage/ipld/memory_indexed_car.hpp"
7
11
8
12
namespace fc ::cli::_node {
9
13
using api::FileRef;
10
14
using api::ImportRes;
11
15
using api::RetrievalOrder;
12
- using primitives::BigInt;
13
16
using primitives::address::Address;
14
- using primitives::address::decodeFromString;
17
+ using proofs::padPiece;
18
+ using ::fc::storage::car::makeCar;
19
+ using ::fc::storage::unixfs::wrapFile;
20
+
15
21
16
22
struct clientRetrieve {
17
23
struct Args {
@@ -48,51 +54,48 @@ namespace fc::cli::_node {
48
54
49
55
CLI_RUN () {
50
56
Node::Api api{argm};
51
- CLI_TRY_TEXT (root, CID::fromString (args.root ), " Invalid root CID: " + args.root );
52
- CLI_TRY_TEXT (cid,
53
- CID::fromString (args.piece_cid ),
54
- " Invalid piece CID: " + args.piece_cid )
55
- if (!args.provider .empty ()) {
56
- CLI_TRY_TEXT (miner,
57
- decodeFromString (args.provider ),
58
- " Invalid Provider Address: " + args.provider )
59
- }
60
- if (!args.from .empty ()) {
61
- CLI_TRY_TEXT (client,
62
- decodeFromString (args.from ),
63
- " Invalid Client Address: " + args.from )
57
+ RetrievalOrder order{};
58
+ auto data_cid{cliArgv<CID>(argv, 0 , " dataCid" )};
59
+ auto path{cliArgv<boost::filesystem::path>(argv, 1 , " path" )};
60
+ order.client = (args.from ? *args.from : cliTry (api._ ->WalletDefaultAddress (), " Getting address of default wallet..." ));
61
+ order.miner = (args.provider ? *args.provider : Address{});
62
+ if (args.max_price ) {
63
+ fmt::print (" max price is {}fil ({}attofil)\n " ,
64
+ args.max_price ->fil ,
65
+ args.max_price ->atto ());
64
66
}
67
+ fmt::print (" retrieving {} to {} {}\n " ,
68
+ data_cid,
69
+ args.car ? " car" : " file" ,
70
+ path);
71
+
65
72
// TODO: continue function
66
- // TODO: positional args
67
73
}
68
74
};
69
75
70
76
struct clientImportData {
71
77
struct Args {
72
- bool car{};
73
- std::string path;
78
+ CLI_BOOL (" car" , " import from a car file instead of a regular file" )car;
74
79
75
80
CLI_OPTS () {
76
- Opts opts;
77
- auto option{opts.add_options ()};
78
- option (" car" ,
79
- po::bool_switch (&car),
80
- " import from a car file instead of a regular file" );
81
- option (" path,p" , po::value (&path), " path to import" );
82
- return opts;
81
+ Opts opts;
82
+ car (opts);
83
+ return opts;
83
84
}
84
85
};
85
86
86
87
CLI_RUN () {
87
88
Node::Api api{argm};
88
- FileRef file_ref{args.path , args.car };
89
- CLI_TRY_TEXT (result, api._ ->ClientImport (file_ref), " Fail of data import" )
90
- std::cout << " File Root CID: " << result.root .toString ().value () << " \n " ;
91
- std::cout << " Data Import Success\n " ;
89
+ auto path{cliArgv<std::string>(argv, 0 , " path to file to import" )};
90
+ FileRef file_ref{path, args.car };
91
+ auto result = cliTry (api._ ->ClientImport (file_ref), " Processing data import" );
92
+ fmt::print (" File Root CID: " + result.root .toString ().value ());
93
+ fmt::print (" Data Import Success" );
92
94
}
93
95
};
94
96
95
97
98
+ <<<<<<< HEAD
96
99
struct clientGenerateCar {
97
100
struct Args {
98
101
std::string in_path;
@@ -103,39 +106,81 @@ namespace fc::cli::_node {
103
106
option (" input-path, inp" , po::value (&in_path), " specifies path to source file" );
104
107
option (" output-path, outp" , po::value (&in_path), " specifies path to generated file" );
105
108
}
106
-
107
- CLI_RUN (){
108
- std::cout<<" Does not supported yet\n " ;
109
- }
110
- };
109
+ =======
110
+ struct Node_client_generateCar : Empty{
111
+ CLI_RUN () {
112
+ auto path_to{cliArgv<boost::filesystem::path>(argv, 0 , " input-path" )};
113
+ auto path_out{cliArgv<boost::filesystem::path>(argv, 1 , " output-path" )};
114
+ >>>>>>> 172a64dc (client methods cli updates)
115
+
116
+ auto tmp_path = path_to.string () + " .unixfs-tmp.car" ;
117
+ auto ipld = cliTry (MemoryIndexedCar::make (tmp_path, true ), " Creting IPLD instance of {}" , tmp_path);
118
+ std::ifstream file{path_to.string ()};
119
+ auto root = cliTry (wrapFile (*ipld, file));
120
+ cliTry (::fc::storage::car::makeSelectiveCar (
121
+ *ipld, {{root, {}}}, path_out.string ()));
122
+ boost::filesystem::remove (tmp_path);
123
+ padPiece (path_out);
124
+ }
111
125
};
112
126
113
127
struct clientLocal : Empty{
114
128
CLI_RUN (){
115
129
Node::Api api {argm};
116
130
CLI_TRY_TEXT (result, api._ ->ClientListImports (), " Fail of getting imports list" );
117
131
for (auto it = result.begin (); it != result.end (); it++){
118
- std::cout<< " Root CID: " << it->root .toString ().value ()<< " \n " ;
119
- std::cout<< " Source: " << it->source << " \n " ;
120
- std::cout<< " Path: " << it->path << " \n " ;
132
+ fmt::print ( " Root CID: {} \n " , it->root .toString ().value ()) ;
133
+ fmt::print ( " Source: {} \n " , it->source ) ;
134
+ fmt::print ( " Path: {} \n " , it->path ) ;
121
135
}
122
136
}
123
137
};
124
138
139
+ <<<<<<< HEAD
125
140
struct clientFind {
126
141
struct Args {
142
+ =======
143
+ struct Node_client_find {
144
+
145
+ };
146
+
147
+ struct Node_client_listRetrieval {
148
+ struct Args {
149
+ CLI_BOOL (" verbose" , " print verbose deal details" )verbose;
150
+ CLI_BOOL (" show-failed" , " show failed/failing deals" )failed_show;
151
+ CLI_BOOL (" completed" , " show completed retrievals" )completed_show;
152
+ >>>>>>> 172a64dc (client methods cli updates)
127
153
128
154
CLI_OPTS (){
129
155
Opts opts;
130
- auto option{opts.add_options ()};
131
-
156
+ verbose (opts);
157
+ failed_show (opts);
158
+ completed_show (opts);
159
+ return opts;
132
160
}
133
161
};
134
162
163
+ CLI_RUN (){
164
+ Node::Api api{argm};
165
+ bool failed_show = !args.failed_show ;
166
+ // TODO: continue;
167
+ // chan = ()
168
+ // if(flag){
169
+ // chan->read([](){
170
+ // print(api->stateRetrivalsDeals)
171
+ //
172
+ // })
173
+ while (true ){
174
+ sleep (10000000000 );
175
+ }
176
+ //
177
+ }
178
+
135
179
};
136
180
137
181
138
182
183
+ <<<<<<< HEAD
139
184
140
185
141
186
@@ -222,4 +267,67 @@ namespace fc::cli::_node {
222
267
}
223
268
};
224
269
>>>>>>> b414cb63 (example client)
270
+ =======
271
+ struct Node_client_inspectDeal{
272
+ struct Args {
273
+ CLI_OPTIONAL (" proposal-cid" , " proposal cid of deal to be inspected" , CID)
274
+ proposal_cid;
275
+ CLI_OPTIONAL (" deal-id" , " id of deal to be inspected" , int ) deal_id;
276
+ CLI_OPTS () {
277
+ Opts opts;
278
+ proposal_cid (opts);
279
+ deal_id (opts);
280
+ return opts;
281
+ }
282
+ };
283
+ CLI_RUN (){
284
+ Node::Api api{argm};
285
+
286
+
287
+
288
+ }
289
+
290
+ };
291
+ struct Node_client_list_deals {
292
+ struct Args {
293
+ CLI_BOOL (" show-failed" , " show failed/failing deals" ) failed_show;
294
+ CLI_OPTS (){
295
+ Opts opts;
296
+ failed_show (opts);
297
+ return opts;
298
+ }
299
+ };
300
+
301
+ CLI_RUN (){
302
+ Node::Api api{argm};
303
+ fmt::print (" Not supported yet\n " );
304
+ auto local_deals = cliTry (api._ ->ClientListDeals (), " Getting local client deals..." );
305
+ // TODO(Markuus): make output;
306
+ }
307
+ };
308
+
309
+ struct Node_client_balances {
310
+ struct Args {
311
+ CLI_OPTIONAL (" client" , " specifies market client" , Address)client;
312
+ CLI_OPTS (){
313
+ Opts opts;
314
+ client (opts);
315
+ return opts;
316
+ }
317
+ };
318
+
319
+ CLI_RUN (){
320
+ Node::Api api{argm};
321
+ Address addr = (args.client ? *args.client : cliTry (api._ ->WalletDefaultAddress (), " Getting address of default wallet..." ));
322
+ auto balance = cliTry (api._ ->StateMarketBalance (addr, TipsetKey ()));
323
+
324
+
325
+ fmt::print (" Escrowed Funds: {}\n " , AttoFil{balance.escrow });
326
+ fmt::print (" Locked Funds: {}\n " , AttoFil{balance.locked });
327
+ // TODO: Reserved and Avaliable
328
+ }
329
+ };
330
+
331
+
332
+ >>>>>>> 172a64dc (client methods cli updates)
225
333
} // namespace fc::cli::_node
0 commit comments