3
3
4
4
#pragma once
5
5
#include " cli/node/node.hpp"
6
+ #include " storage/car/car.hpp"
7
+ #include " storage/ipld/memory_indexed_car.hpp"
8
+ #include " storage/unixfs/unixfs.hpp"
9
+ #include " storage/ipld/memory_indexed_car.hpp"
6
10
7
11
namespace fc ::cli::_node {
8
12
using api::FileRef;
9
13
using api::ImportRes;
10
14
using api::RetrievalOrder;
11
- using primitives::BigInt;
12
15
using primitives::address::Address;
13
- using primitives::address::decodeFromString;
16
+ using proofs::padPiece;
17
+ using ::fc::storage::car::makeCar;
18
+ using ::fc::storage::unixfs::wrapFile;
19
+
14
20
15
21
struct clientRetrieve {
16
22
struct Args {
@@ -47,51 +53,48 @@ namespace fc::cli::_node {
47
53
48
54
CLI_RUN () {
49
55
Node::Api api{argm};
50
- CLI_TRY_TEXT (root, CID::fromString (args.root ), " Invalid root CID: " + args.root );
51
- CLI_TRY_TEXT (cid,
52
- CID::fromString (args.piece_cid ),
53
- " Invalid piece CID: " + args.piece_cid )
54
- if (!args.provider .empty ()) {
55
- CLI_TRY_TEXT (miner,
56
- decodeFromString (args.provider ),
57
- " Invalid Provider Address: " + args.provider )
58
- }
59
- if (!args.from .empty ()) {
60
- CLI_TRY_TEXT (client,
61
- decodeFromString (args.from ),
62
- " Invalid Client Address: " + args.from )
56
+ RetrievalOrder order{};
57
+ auto data_cid{cliArgv<CID>(argv, 0 , " dataCid" )};
58
+ auto path{cliArgv<boost::filesystem::path>(argv, 1 , " path" )};
59
+ order.client = (args.from ? *args.from : cliTry (api._ ->WalletDefaultAddress (), " Getting address of default wallet..." ));
60
+ order.miner = (args.provider ? *args.provider : Address{});
61
+ if (args.max_price ) {
62
+ fmt::print (" max price is {}fil ({}attofil)\n " ,
63
+ args.max_price ->fil ,
64
+ args.max_price ->atto ());
63
65
}
66
+ fmt::print (" retrieving {} to {} {}\n " ,
67
+ data_cid,
68
+ args.car ? " car" : " file" ,
69
+ path);
70
+
64
71
// TODO: continue function
65
- // TODO: positional args
66
72
}
67
73
};
68
74
69
75
struct clientImportData {
70
76
struct Args {
71
- bool car{};
72
- std::string path;
77
+ CLI_BOOL (" car" , " import from a car file instead of a regular file" )car;
73
78
74
79
CLI_OPTS () {
75
- Opts opts;
76
- auto option{opts.add_options ()};
77
- option (" car" ,
78
- po::bool_switch (&car),
79
- " import from a car file instead of a regular file" );
80
- option (" path,p" , po::value (&path), " path to import" );
81
- return opts;
80
+ Opts opts;
81
+ car (opts);
82
+ return opts;
82
83
}
83
84
};
84
85
85
86
CLI_RUN () {
86
87
Node::Api api{argm};
87
- FileRef file_ref{args.path , args.car };
88
- CLI_TRY_TEXT (result, api._ ->ClientImport (file_ref), " Fail of data import" )
89
- std::cout << " File Root CID: " << result.root .toString ().value () << " \n " ;
90
- std::cout << " Data Import Success\n " ;
88
+ auto path{cliArgv<std::string>(argv, 0 , " path to file to import" )};
89
+ FileRef file_ref{path, args.car };
90
+ auto result = cliTry (api._ ->ClientImport (file_ref), " Processing data import" );
91
+ fmt::print (" File Root CID: " + result.root .toString ().value ());
92
+ fmt::print (" Data Import Success" );
91
93
}
92
94
};
93
95
94
96
97
+ <<<<<<< HEAD
95
98
struct clientGenerateCar {
96
99
struct Args {
97
100
std::string in_path;
@@ -102,42 +105,145 @@ namespace fc::cli::_node {
102
105
option (" input-path, inp" , po::value (&in_path), " specifies path to source file" );
103
106
option (" output-path, outp" , po::value (&in_path), " specifies path to generated file" );
104
107
}
105
-
106
- CLI_RUN (){
107
- std::cout<<" Does not supported yet\n " ;
108
- }
109
- };
108
+ =======
109
+ struct Node_client_generateCar : Empty{
110
+ CLI_RUN () {
111
+ auto path_to{cliArgv<boost::filesystem::path>(argv, 0 , " input-path" )};
112
+ auto path_out{cliArgv<boost::filesystem::path>(argv, 1 , " output-path" )};
113
+ >>>>>>> 172a64dc (client methods cli updates)
114
+
115
+ auto tmp_path = path_to.string () + " .unixfs-tmp.car" ;
116
+ auto ipld = cliTry (MemoryIndexedCar::make (tmp_path, true ), " Creting IPLD instance of {}" , tmp_path);
117
+ std::ifstream file{path_to.string ()};
118
+ auto root = cliTry (wrapFile (*ipld, file));
119
+ cliTry (::fc::storage::car::makeSelectiveCar (
120
+ *ipld, {{root, {}}}, path_out.string ()));
121
+ boost::filesystem::remove (tmp_path);
122
+ padPiece (path_out);
123
+ }
110
124
};
111
125
112
126
struct clientLocal : Empty{
113
127
CLI_RUN (){
114
128
Node::Api api {argm};
115
129
CLI_TRY_TEXT (result, api._ ->ClientListImports (), " Fail of getting imports list" );
116
130
for (auto it = result.begin (); it != result.end (); it++){
117
- std::cout<< " Root CID: " << it->root .toString ().value ()<< " \n " ;
118
- std::cout<< " Source: " << it->source << " \n " ;
119
- std::cout<< " Path: " << it->path << " \n " ;
131
+ fmt::print ( " Root CID: {} \n " , it->root .toString ().value ()) ;
132
+ fmt::print ( " Source: {} \n " , it->source ) ;
133
+ fmt::print ( " Path: {} \n " , it->path ) ;
120
134
}
121
135
}
122
136
};
123
137
138
+ <<<<<<< HEAD
124
139
struct clientFind {
125
140
struct Args {
141
+ =======
142
+ struct Node_client_find {
143
+
144
+ };
145
+
146
+ struct Node_client_listRetrieval {
147
+ struct Args {
148
+ CLI_BOOL (" verbose" , " print verbose deal details" )verbose;
149
+ CLI_BOOL (" show-failed" , " show failed/failing deals" )failed_show;
150
+ CLI_BOOL (" completed" , " show completed retrievals" )completed_show;
151
+ >>>>>>> 172a64dc (client methods cli updates)
126
152
127
153
CLI_OPTS (){
128
154
Opts opts;
129
- auto option{opts.add_options ()};
130
-
155
+ verbose (opts);
156
+ failed_show (opts);
157
+ completed_show (opts);
158
+ return opts;
131
159
}
132
160
};
133
161
162
+ CLI_RUN (){
163
+ Node::Api api{argm};
164
+ bool failed_show = !args.failed_show ;
165
+ // TODO: continue;
166
+ // chan = ()
167
+ // if(flag){
168
+ // chan->read([](){
169
+ // print(api->stateRetrivalsDeals)
170
+ //
171
+ // })
172
+ while (true ){
173
+ sleep (10000000000 );
174
+ }
175
+ //
176
+ }
177
+
134
178
};
135
179
136
180
137
181
182
+ <<<<<<< HEAD
138
183
139
184
140
185
186
+ =======
187
+ struct Node_client_inspectDeal {
188
+ struct Args {
189
+ CLI_OPTIONAL (" proposal-cid" , " proposal cid of deal to be inspected" , CID)
190
+ proposal_cid;
191
+ CLI_OPTIONAL (" deal-id" , " id of deal to be inspected" , int ) deal_id;
192
+ CLI_OPTS () {
193
+ Opts opts;
194
+ proposal_cid (opts);
195
+ deal_id (opts);
196
+ return opts;
197
+ }
198
+ };
199
+ CLI_RUN (){
200
+ Node::Api api{argm};
201
+
202
+
203
+
204
+ }
205
+
206
+ };
207
+ struct Node_client_list_deals {
208
+ struct Args {
209
+ CLI_BOOL (" show-failed" , " show failed/failing deals" ) failed_show;
210
+ CLI_OPTS (){
211
+ Opts opts;
212
+ failed_show (opts);
213
+ return opts;
214
+ }
215
+ };
216
+
217
+ CLI_RUN (){
218
+ Node::Api api{argm};
219
+ fmt::print (" Not supported yet\n " );
220
+ auto local_deals = cliTry (api._ ->ClientListDeals (), " Getting local client deals..." );
221
+ // TODO(Markuus): make output;
222
+ }
223
+ };
224
+
225
+ struct Node_client_balances {
226
+ struct Args {
227
+ CLI_OPTIONAL (" client" , " specifies market client" , Address)client;
228
+ CLI_OPTS (){
229
+ Opts opts;
230
+ client (opts);
231
+ return opts;
232
+ }
233
+ };
234
+
235
+ CLI_RUN (){
236
+ Node::Api api{argm};
237
+ Address addr = (args.client ? *args.client : cliTry (api._ ->WalletDefaultAddress (), " Getting address of default wallet..." ));
238
+ auto balance = cliTry (api._ ->StateMarketBalance (addr, TipsetKey ()));
239
+
240
+
241
+ fmt::print (" Escrowed Funds: {}\n " , AttoFil{balance.escrow });
242
+ fmt::print (" Locked Funds: {}\n " , AttoFil{balance.locked });
243
+ // TODO: Reserved and Avaliable
244
+ }
245
+ };
246
+ >>>>>>> 172a64dc (client methods cli updates)
141
247
142
248
143
249
} // namespace fc::cli::_node
0 commit comments