Skip to content

Commit d915189

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

File tree

1 file changed

+111
-46
lines changed

1 file changed

+111
-46
lines changed

core/cli/node/client.hpp

Lines changed: 111 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
#include "storage/car/car.hpp"
77
#include "storage/ipld/memory_indexed_car.hpp"
88
#include "storage/unixfs/unixfs.hpp"
9-
#include "storage/ipld/memory_indexed_car.hpp"
109

1110
namespace fc::cli::_node {
1211
using api::FileRef;
1312
using api::ImportRes;
1413
using api::RetrievalOrder;
15-
using primitives::address::Address;
16-
using proofs::padPiece;
1714
using ::fc::storage::car::makeCar;
1815
using ::fc::storage::unixfs::wrapFile;
19-
16+
using primitives::address::Address;
17+
using proofs::padPiece;
2018

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

7576
struct clientImportData {
7677
struct Args {
77-
CLI_BOOL("car", "import from a car file instead of a regular file")car;
78+
CLI_BOOL("car", "import from a car file instead of a regular file") car;
7879

7980
CLI_OPTS() {
80-
Opts opts;
81-
car(opts);
82-
return opts;
81+
Opts opts;
82+
car(opts);
83+
return opts;
8384
}
8485
};
8586

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

98+
<<<<<<< HEAD
9699

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

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

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

154+
<<<<<<< HEAD
138155
<<<<<<< HEAD
139156
struct clientFind{
140157
struct Args{
141158
=======
142159
struct Node_client_find{
160+
=======
161+
struct Node_client_find {};
162+
>>>>>>> f1466404 (client updates)
143163

144-
};
145-
146-
struct Node_client_listRetrieval{
164+
struct Node_client_listRetrieval {
147165
struct Args {
166+
<<<<<<< HEAD
148167
CLI_BOOL("verbose", "print verbose deal details")verbose;
149168
CLI_BOOL("show-failed", "show failed/failing deals")failed_show;
150169
CLI_BOOL("completed", "show completed retrievals")completed_show;
151170
>>>>>>> 172a64dc (client methods cli updates)
171+
=======
172+
CLI_BOOL("verbose", "print verbose deal details") verbose;
173+
CLI_BOOL("show-failed", "show failed/failing deals") failed_show;
174+
CLI_BOOL("completed", "show completed retrievals") completed_show;
175+
>>>>>>> f1466404 (client updates)
152176

153-
CLI_OPTS(){
177+
CLI_OPTS() {
154178
Opts opts;
155179
verbose(opts);
156180
failed_show(opts);
@@ -159,24 +183,24 @@ namespace fc::cli::_node {
159183
}
160184
};
161185

162-
CLI_RUN(){
186+
CLI_RUN() {
163187
Node::Api api{argm};
164188
bool failed_show = !args.failed_show;
165-
//TODO: continue;
189+
// TODO: continue;
166190
// chan = ()
167191
// if(flag){
168192
// chan->read([](){
169193
// print(api->stateRetrivalsDeals)
170194
//
171195
// })
172-
while(true){
173-
sleep(10000000000);
174-
}
196+
while (true) {
197+
sleep(10000000000);
198+
}
175199
//
176200
}
177-
178201
};
179202

203+
<<<<<<< HEAD
180204

181205

182206
<<<<<<< HEAD
@@ -185,6 +209,9 @@ namespace fc::cli::_node {
185209

186210
=======
187211
struct Node_client_inspectDeal{
212+
=======
213+
struct Node_client_inspectDeal {
214+
>>>>>>> f1466404 (client updates)
188215
struct Args {
189216
CLI_OPTIONAL("proposal-cid", "proposal cid of deal to be inspected", CID)
190217
proposal_cid;
@@ -196,79 +223,117 @@ namespace fc::cli::_node {
196223
return opts;
197224
}
198225
};
199-
CLI_RUN(){
226+
CLI_RUN() {
200227
Node::Api api{argm};
201-
202-
203-
204228
}
205-
206229
};
207-
struct Node_client_list_deals{
230+
struct Node_client_list_deals {
208231
struct Args {
209232
CLI_BOOL("show-failed", "show failed/failing deals") failed_show;
210-
CLI_OPTS(){
233+
CLI_OPTS() {
211234
Opts opts;
212235
failed_show(opts);
213236
return opts;
214237
}
215238
};
216239

217-
CLI_RUN(){
240+
CLI_RUN() {
218241
Node::Api api{argm};
219242
fmt::print("Not supported yet\n");
220-
auto local_deals = cliTry(api._->ClientListDeals(), "Getting local client deals...");
243+
auto local_deals =
244+
cliTry(api._->ClientListDeals(), "Getting local client deals...");
221245
// TODO(Markuus): make output;
222246
}
223247
};
224248

225-
struct Node_client_balances{
226-
struct Args{
227-
CLI_OPTIONAL("client", "specifies market client", Address)client;
228-
CLI_OPTS(){
229-
Opts opts;
249+
struct Node_client_balances {
250+
struct Args {
251+
CLI_OPTIONAL("client", "specifies market client", Address) client;
252+
CLI_OPTS() {
253+
Opts opts;
230254
client(opts);
231255
return opts;
232256
}
233257
};
234258

235-
CLI_RUN(){
259+
CLI_RUN() {
236260
Node::Api api{argm};
237-
Address addr = (args.client ? *args.client : cliTry(api._->WalletDefaultAddress(), "Getting address of default wallet..."));
261+
Address addr =
262+
(args.client ? *args.client
263+
: cliTry(api._->WalletDefaultAddress(),
264+
"Getting address of default wallet..."));
238265
auto balance = cliTry(api._->StateMarketBalance(addr, TipsetKey()));
239266

240-
241267
fmt::print(" Escrowed Funds: {}\n", AttoFil{balance.escrow});
242268
fmt::print(" Locked Funds: {}\n", AttoFil{balance.locked});
243-
//TODO: Reserved and Avaliable
269+
// TODO: Reserved and Avaliable
244270
}
245271
};
246272
<<<<<<< HEAD
247273
>>>>>>> 172a64dc (client methods cli updates)
248274
=======
249275

250-
251-
struct Node_client_getDeal: Empty{
252-
CLI_RUN(){
276+
struct Node_client_getDeal : Empty {
277+
CLI_RUN() {
253278
Node::Api api{argm};
254279
auto proposal_cid{cliArgv<CID>(argv, 0, "proposal cid of deal to get")};
255280
// TODO: Client getDealInfo
256281
}
257282
};
258283

259-
struct Node_client_stat: Empty{
284+
struct Node_client_stat : Empty {
260285
CLI_RUN() {
261286
Node::Api api{argm};
262287
auto cid{cliArgv<CID>(argv, 0, " cid of localy stored file")};
263-
//auto deal_size = cliTry(api._->);
264-
//TODO: CLientDealSize;
288+
// auto deal_size = cliTry(api._->);
289+
// TODO: CLientDealSize;
265290
}
266-
267291
};
268292

293+
struct Node_client_listTransfers {
294+
struct Args {
295+
CLI_BOOL("completed", "show completed data transfers") completed;
296+
CLI_BOOL("watch",
297+
"watch deal updates in real-time, rather than a one time list")
298+
watch;
299+
CLI_BOOL("show-failed", "show failed/cancelled transfers") failed_show;
269300

301+
CLI_OPTS() {
302+
Opts opts;
303+
completed(opts);
304+
watch(opts);
305+
failed_show(opts);
306+
return opts;
307+
}
308+
};
270309

310+
<<<<<<< HEAD
271311
>>>>>>> 490821f3 (client updates)
312+
=======
313+
CLI_RUN() {
314+
fmt::print("Not supported yet");
315+
// TODO: ClientListDataTransfers
316+
}
317+
};
318+
>>>>>>> f1466404 (client updates)
319+
320+
struct Node_client_grantDatacap {
321+
struct Args {
322+
CLI_OPTIONAL("from",
323+
"specifies the adrress of notary to send message from",
324+
Address)
325+
from;
326+
CLI_OPTS() {
327+
Opts opts;
328+
from(opts);
329+
return opts;
330+
}
331+
};
272332

333+
CLI_RUN() {
334+
auto target{cliArgv<Address>(argv, 0, "target address")};
335+
auto allowness{cliArgv<AttoFil>(argv, 1, "amount")};
336+
}
337+
};
273338

274339
} // namespace fc::cli::_node

0 commit comments

Comments
 (0)