hippius 0.1.7__py3-none-any.whl → 0.1.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hippius
3
- Version: 0.1.7
3
+ Version: 0.1.9
4
4
  Summary: Python SDK and CLI for Hippius blockchain storage
5
5
  Home-page: https://github.com/thenervelab/hippius-sdk
6
6
  Author: Dubs
@@ -67,7 +67,7 @@ client = HippiusClient()
67
67
  # Or specify custom endpoints
68
68
  client = HippiusClient(
69
69
  ipfs_gateway="https://ipfs.io", # For downloads (default)
70
- ipfs_api_url="https://relay-fr.hippius.network", # For uploads (default)
70
+ ipfs_api_url="https://store.hippius.network", # For uploads (default)
71
71
  )
72
72
 
73
73
  # Upload a file to IPFS
@@ -313,6 +313,64 @@ This command provides detailed information about each erasure-coded file includi
313
313
  - Miners storing the file
314
314
  - Reconstruction command
315
315
 
316
+ The `ec-files` command is optimized for performance through parallel processing and intelligent filtering, making it efficient even with large numbers of files.
317
+
318
+ #### Performance Considerations
319
+
320
+ The erasure coding implementation has been optimized for:
321
+
322
+ 1. **Speed**: Parallel processing for file operations
323
+ 2. **Memory efficiency**: Files are processed in chunks to minimize memory usage
324
+ 3. **Auto-tuning**: Parameters like chunk size are automatically adjusted for small files
325
+ 4. **Intelligent filtering**: The system can quickly identify potential erasure-coded files
326
+
327
+ For extremely large files (>1GB), consider using larger chunk sizes to improve performance:
328
+
329
+ ```bash
330
+ hippius erasure-code large_video.mp4 --chunk-size 10485760 # 10MB chunks
331
+ ```
332
+
333
+ #### Directory Support for Erasure Coding
334
+
335
+ Hippius SDK now supports applying erasure coding to entire directories:
336
+
337
+ ```bash
338
+ # Apply erasure coding to an entire directory
339
+ hippius erasure-code my_directory/
340
+
341
+ # The CLI will detect that it's a directory and offer two options:
342
+ # 1. Archive the directory first, then erasure code the archive
343
+ # 2. Apply erasure coding to each file in the directory individually
344
+ ```
345
+
346
+ When choosing the second option, the system will process each file in the directory individually, adjusting parameters like chunk size automatically for small files. A summary of the operation will be displayed, showing:
347
+ - Total files processed
348
+ - Successfully coded files with their metadata CIDs
349
+ - Any files that failed, with error details
350
+
351
+ To reconstruct a file from erasure-coded chunks:
352
+
353
+ ```bash
354
+ hippius reconstruct QmMetadataCID reconstructed_filename
355
+ ```
356
+
357
+ #### Default Address Management
358
+
359
+ Hippius SDK now allows setting a default address for read-only operations, making it easier to use commands like `files` and `ec-files` without specifying an account address each time:
360
+
361
+ ```bash
362
+ # Set a default address for read-only operations
363
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
364
+
365
+ # View the currently set default address
366
+ hippius address get-default
367
+
368
+ # Clear the default address
369
+ hippius address clear-default
370
+ ```
371
+
372
+ Once a default address is set, commands like `hippius files` and `hippius ec-files` will automatically use this address when no explicit address is provided.
373
+
316
374
  #### Troubleshooting
317
375
 
318
376
  1. **IPFS Connection Issues**: Make sure you have either:
@@ -333,7 +391,30 @@ This command provides detailed information about each erasure-coded file includi
333
391
  which hippius
334
392
  ```
335
393
 
336
- 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
394
+ 4. **Default Address Issues**: If you receive errors about missing account address:
395
+ ```bash
396
+ # Set a default address for read-only operations
397
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
398
+ ```
399
+
400
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
401
+
402
+ 6. **Erasure Coding Problems**:
403
+ - **"Wrong length for input blocks"**: This typically happens with very small files
404
+ ```bash
405
+ # Try smaller k and m values for small files
406
+ hippius erasure-code small_file.txt --k 2 --m 3
407
+ ```
408
+ - **Directories can't be directly coded**: Use the directory support option when prompted
409
+ - **"zfec is required"**: Install the missing package
410
+ ```bash
411
+ pip install zfec
412
+ poetry add zfec
413
+ ```
414
+ - **Slow performance with large files**: Increase chunk size
415
+ ```bash
416
+ hippius erasure-code large_file.mp4 --chunk-size 5242880 # 5MB chunks
417
+ ```
337
418
 
338
419
  ## Command Line Interface
339
420
 
@@ -346,7 +427,7 @@ The Hippius SDK includes a powerful command-line interface (CLI) that provides a
346
427
  hippius --help
347
428
 
348
429
  # Set global options
349
- hippius --gateway https://ipfs.io --api-url https://relay-fr.hippius.network --verbose
430
+ hippius --gateway https://ipfs.io --api-url https://store.hippius.network --verbose
350
431
  ```
351
432
 
352
433
  ### IPFS Operations
@@ -431,7 +512,7 @@ hippius ec-files --all-miners
431
512
  hippius ec-files --show-chunks
432
513
  ```
433
514
 
434
- The `ec-files` command makes it easy to track and manage your erasure-coded files separately from regular files. It provides the metadata CID needed for reconstruction and information about chunk distribution.
515
+ The `ec-files` command has been optimized for performance and can now handle large numbers of files efficiently through parallel processing.
435
516
 
436
517
  ### Using Environment Variables
437
518
 
@@ -439,7 +520,7 @@ The CLI automatically reads from your `.env` file for common settings:
439
520
 
440
521
  ```
441
522
  IPFS_GATEWAY=https://ipfs.io
442
- IPFS_API_URL=https://relay-fr.hippius.network
523
+ IPFS_API_URL=https://store.hippius.network
443
524
  SUBSTRATE_URL=wss://rpc.hippius.network
444
525
  SUBSTRATE_SEED_PHRASE="your twelve word seed phrase..."
445
526
  SUBSTRATE_DEFAULT_MINERS=miner1,miner2,miner3
@@ -546,13 +627,14 @@ The configuration is organized in the following sections:
546
627
  {
547
628
  "ipfs": {
548
629
  "gateway": "https://ipfs.io",
549
- "api_url": "https://relay-fr.hippius.network",
630
+ "api_url": "https://store.hippius.network",
550
631
  "local_ipfs": false
551
632
  },
552
633
  "substrate": {
553
634
  "url": "wss://rpc.hippius.network",
554
635
  "seed_phrase": null,
555
- "default_miners": []
636
+ "default_miners": [],
637
+ "default_address": null
556
638
  },
557
639
  "encryption": {
558
640
  "encrypt_by_default": false,
@@ -737,7 +819,13 @@ hippius --help
737
819
  which hippius
738
820
  ```
739
821
 
740
- 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
822
+ 4. **Default Address Issues**: If you receive errors about missing account address:
823
+ ```bash
824
+ # Set a default address for read-only operations
825
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
826
+ ```
827
+
828
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
741
829
 
742
830
  ## Contributing
743
831
 
@@ -0,0 +1,10 @@
1
+ hippius_sdk/__init__.py,sha256=fs2pZ_wIl3eaUz6qFprcRsZhYakqv6-qm468NZh-8h4,1260
2
+ hippius_sdk/cli.py,sha256=0IQZh2by6kN8Sol3eDFfZzgj5otBeIOKC4lq2wIejOc,76317
3
+ hippius_sdk/client.py,sha256=54tsg4k29sqt3F77LQJ_vhzzTR73QuZ_edqI_BvZM1E,14905
4
+ hippius_sdk/config.py,sha256=gTr8EXeZ3jJNchcG9WyjbQdpPRHTxL5IWZgyIAm_X-c,22869
5
+ hippius_sdk/ipfs.py,sha256=9fds5MJwVb7t8IqROM70x9fWgyk9_Ot5psat_hMnRN8,63969
6
+ hippius_sdk/substrate.py,sha256=fa8K8vVdYGVtB3VNJ-_Vdw8bOxDUajFmj6se-rHZveQ,30853
7
+ hippius-0.1.9.dist-info/METADATA,sha256=SPXMFKAJ_at35FEPB9uDMi3iBP7EXMLxskPvLxHmCQE,28000
8
+ hippius-0.1.9.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
9
+ hippius-0.1.9.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
10
+ hippius-0.1.9.dist-info/RECORD,,
hippius_sdk/cli.py CHANGED
@@ -1608,8 +1608,8 @@ examples:
1608
1608
  )
1609
1609
  parser.add_argument(
1610
1610
  "--api-url",
1611
- default=get_config_value("ipfs", "api_url", "https://relay-fr.hippius.network"),
1612
- help="IPFS API URL for uploads (default: from config or https://relay-fr.hippius.network)",
1611
+ default=get_config_value("ipfs", "api_url", "https://store.hippius.network"),
1612
+ help="IPFS API URL for uploads (default: from config or https://store.hippius.network)",
1613
1613
  )
1614
1614
  parser.add_argument(
1615
1615
  "--local-ipfs",
hippius_sdk/client.py CHANGED
@@ -49,7 +49,7 @@ class HippiusClient:
49
49
 
50
50
  if ipfs_api_url is None:
51
51
  ipfs_api_url = get_config_value(
52
- "ipfs", "api_url", "https://relay-fr.hippius.network"
52
+ "ipfs", "api_url", "https://store.hippius.network"
53
53
  )
54
54
 
55
55
  # Check if local IPFS is enabled in config
hippius_sdk/config.py CHANGED
@@ -19,7 +19,7 @@ CONFIG_FILE = os.path.join(CONFIG_DIR, "config.json")
19
19
  DEFAULT_CONFIG = {
20
20
  "ipfs": {
21
21
  "gateway": "https://ipfs.io",
22
- "api_url": "https://relay-fr.hippius.network",
22
+ "api_url": "https://store.hippius.network",
23
23
  "local_ipfs": False,
24
24
  },
25
25
  "substrate": {
hippius_sdk/ipfs.py CHANGED
@@ -62,7 +62,7 @@ class IPFSClient:
62
62
 
63
63
  if api_url is None:
64
64
  api_url = get_config_value(
65
- "ipfs", "api_url", "https://relay-fr.hippius.network"
65
+ "ipfs", "api_url", "https://store.hippius.network"
66
66
  )
67
67
 
68
68
  # Check if local IPFS is enabled in config
hippius_sdk/substrate.py CHANGED
@@ -6,6 +6,7 @@ Note: This functionality is coming soon and not implemented yet.
6
6
 
7
7
  import os
8
8
  import json
9
+ import uuid
9
10
  from typing import Dict, Any, Optional, List, Union
10
11
  from substrateinterface import SubstrateInterface, Keypair
11
12
  from dotenv import load_dotenv
@@ -205,8 +206,8 @@ class SubstrateClient:
205
206
  """
206
207
  Submit a storage request for IPFS files to the marketplace.
207
208
 
208
- This method batches all files into a single transaction to efficiently store
209
- multiple files at once.
209
+ This method creates a JSON file with the list of files to pin, uploads it to IPFS,
210
+ and submits the CID of this file to the chain.
210
211
 
211
212
  Args:
212
213
  files: List of FileInput objects or dictionaries with fileHash and fileName
@@ -241,7 +242,7 @@ class SubstrateClient:
241
242
  file_inputs.append(file)
242
243
 
243
244
  # Print what is being submitted
244
- print(f"Submitting storage request for {len(file_inputs)} files as a batch:")
245
+ print(f"Preparing storage request for {len(file_inputs)} files:")
245
246
  for file in file_inputs:
246
247
  print(f" - {file.file_name}: {file.file_hash}")
247
248
 
@@ -261,22 +262,50 @@ class SubstrateClient:
261
262
  )
262
263
  print(f"Connected to Substrate node at {self.url}")
263
264
 
264
- # Format files for the batch call - all files are included in a single array
265
- formatted_files = []
265
+ # Step 1: Create a JSON file with the list of files to pin
266
+ file_list = []
266
267
  for file_input in file_inputs:
267
- formatted_files.append(
268
- {
269
- "file_hash": file_input.file_hash,
270
- "file_name": file_input.file_name,
271
- }
268
+ file_list.append(
269
+ {"filename": file_input.file_name, "cid": file_input.file_hash}
272
270
  )
273
271
 
274
- # Create call parameters with all files in a single batch
272
+ # Convert to JSON
273
+ files_json = json.dumps(file_list, indent=2)
274
+ print(f"Created file list with {len(file_list)} entries")
275
+
276
+ # Step 2: Upload the JSON file to IPFS
277
+ import tempfile
278
+ from hippius_sdk.ipfs import IPFSClient
279
+
280
+ ipfs_client = IPFSClient()
281
+
282
+ # Create a temporary file with the JSON content
283
+ with tempfile.NamedTemporaryFile(
284
+ mode="w+", suffix=".json", delete=False
285
+ ) as temp_file:
286
+ temp_file_path = temp_file.name
287
+ temp_file.write(files_json)
288
+
289
+ try:
290
+ print("Uploading file list to IPFS...")
291
+ upload_result = ipfs_client.upload_file(temp_file_path)
292
+ files_list_cid = upload_result["cid"]
293
+ print(f"File list uploaded to IPFS with CID: {files_list_cid}")
294
+ finally:
295
+ # Clean up the temporary file
296
+ if os.path.exists(temp_file_path):
297
+ os.remove(temp_file_path)
298
+
299
+ # Step 3: Submit the CID of the JSON file to the chain
300
+ # Create call parameters with the CID of the JSON file
275
301
  call_params = {
276
- "files_input": formatted_files,
277
- "miner_ids": miner_ids
278
- if miner_ids
279
- else [], # Always include miner_ids, empty array if not specified
302
+ "files_input": [
303
+ {
304
+ "file_hash": files_list_cid,
305
+ "file_name": f"files_list_{uuid.uuid4()}", # Generate a unique ID
306
+ }
307
+ ],
308
+ "miner_ids": miner_ids if miner_ids else [],
280
309
  }
281
310
 
282
311
  # Create the call to the marketplace
@@ -300,7 +329,9 @@ class SubstrateClient:
300
329
  call=call, keypair=self._keypair
301
330
  )
302
331
 
303
- print(f"Submitting batch transaction for {len(formatted_files)} files...")
332
+ print(
333
+ f"Submitting transaction to store {len(file_list)} files via file list CID..."
334
+ )
304
335
 
305
336
  # Submit the transaction
306
337
  response = self._substrate.submit_extrinsic(
@@ -310,11 +341,10 @@ class SubstrateClient:
310
341
  # Get the transaction hash
311
342
  tx_hash = response.extrinsic_hash
312
343
 
313
- print(f"Batch transaction submitted successfully!")
344
+ print(f"Transaction submitted successfully!")
314
345
  print(f"Transaction hash: {tx_hash}")
315
- print(
316
- f"All {len(formatted_files)} files have been stored in a single transaction"
317
- )
346
+ print(f"File list CID: {files_list_cid}")
347
+ print(f"All {len(file_list)} files will be stored through this request")
318
348
 
319
349
  return tx_hash
320
350
 
@@ -1,10 +0,0 @@
1
- hippius_sdk/__init__.py,sha256=fs2pZ_wIl3eaUz6qFprcRsZhYakqv6-qm468NZh-8h4,1260
2
- hippius_sdk/cli.py,sha256=RgRvBrrZ5PhFkfrkeGFP7byc1V_sbCJnLElrnCtr14A,76323
3
- hippius_sdk/client.py,sha256=RV9MPs9nFW7dd8rVMgJ2giPrX6ETOnvlJDqm9uwuQi8,14908
4
- hippius_sdk/config.py,sha256=NzAkmFaeE9-inHCCYL9cl97dZmSndx6OSgj9cQBWMAA,22872
5
- hippius_sdk/ipfs.py,sha256=RKIDFuYqPFZfbHTi-oMa_IfAUUmtJX1nFOFnOKlnbBk,63972
6
- hippius_sdk/substrate.py,sha256=ulLL3WcDHLm8eU_MuvqbzrCn2fbCdDDReJcxthMtFDw,29661
7
- hippius-0.1.7.dist-info/METADATA,sha256=u_wKxSFdznRWbflR4OLBJ7XbFBXBEB_sQjohUv5UD9g,24689
8
- hippius-0.1.7.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
9
- hippius-0.1.7.dist-info/entry_points.txt,sha256=b1lo60zRXmv1ud-c5BC-cJcAfGE5FD4qM_nia6XeQtM,98
10
- hippius-0.1.7.dist-info/RECORD,,