hippius 0.1.7__tar.gz → 0.1.9__tar.gz

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
 
@@ -36,7 +36,7 @@ client = HippiusClient()
36
36
  # Or specify custom endpoints
37
37
  client = HippiusClient(
38
38
  ipfs_gateway="https://ipfs.io", # For downloads (default)
39
- ipfs_api_url="https://relay-fr.hippius.network", # For uploads (default)
39
+ ipfs_api_url="https://store.hippius.network", # For uploads (default)
40
40
  )
41
41
 
42
42
  # Upload a file to IPFS
@@ -282,6 +282,64 @@ This command provides detailed information about each erasure-coded file includi
282
282
  - Miners storing the file
283
283
  - Reconstruction command
284
284
 
285
+ The `ec-files` command is optimized for performance through parallel processing and intelligent filtering, making it efficient even with large numbers of files.
286
+
287
+ #### Performance Considerations
288
+
289
+ The erasure coding implementation has been optimized for:
290
+
291
+ 1. **Speed**: Parallel processing for file operations
292
+ 2. **Memory efficiency**: Files are processed in chunks to minimize memory usage
293
+ 3. **Auto-tuning**: Parameters like chunk size are automatically adjusted for small files
294
+ 4. **Intelligent filtering**: The system can quickly identify potential erasure-coded files
295
+
296
+ For extremely large files (>1GB), consider using larger chunk sizes to improve performance:
297
+
298
+ ```bash
299
+ hippius erasure-code large_video.mp4 --chunk-size 10485760 # 10MB chunks
300
+ ```
301
+
302
+ #### Directory Support for Erasure Coding
303
+
304
+ Hippius SDK now supports applying erasure coding to entire directories:
305
+
306
+ ```bash
307
+ # Apply erasure coding to an entire directory
308
+ hippius erasure-code my_directory/
309
+
310
+ # The CLI will detect that it's a directory and offer two options:
311
+ # 1. Archive the directory first, then erasure code the archive
312
+ # 2. Apply erasure coding to each file in the directory individually
313
+ ```
314
+
315
+ 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:
316
+ - Total files processed
317
+ - Successfully coded files with their metadata CIDs
318
+ - Any files that failed, with error details
319
+
320
+ To reconstruct a file from erasure-coded chunks:
321
+
322
+ ```bash
323
+ hippius reconstruct QmMetadataCID reconstructed_filename
324
+ ```
325
+
326
+ #### Default Address Management
327
+
328
+ 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:
329
+
330
+ ```bash
331
+ # Set a default address for read-only operations
332
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
333
+
334
+ # View the currently set default address
335
+ hippius address get-default
336
+
337
+ # Clear the default address
338
+ hippius address clear-default
339
+ ```
340
+
341
+ 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.
342
+
285
343
  #### Troubleshooting
286
344
 
287
345
  1. **IPFS Connection Issues**: Make sure you have either:
@@ -302,7 +360,30 @@ This command provides detailed information about each erasure-coded file includi
302
360
  which hippius
303
361
  ```
304
362
 
305
- 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
363
+ 4. **Default Address Issues**: If you receive errors about missing account address:
364
+ ```bash
365
+ # Set a default address for read-only operations
366
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
367
+ ```
368
+
369
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
370
+
371
+ 6. **Erasure Coding Problems**:
372
+ - **"Wrong length for input blocks"**: This typically happens with very small files
373
+ ```bash
374
+ # Try smaller k and m values for small files
375
+ hippius erasure-code small_file.txt --k 2 --m 3
376
+ ```
377
+ - **Directories can't be directly coded**: Use the directory support option when prompted
378
+ - **"zfec is required"**: Install the missing package
379
+ ```bash
380
+ pip install zfec
381
+ poetry add zfec
382
+ ```
383
+ - **Slow performance with large files**: Increase chunk size
384
+ ```bash
385
+ hippius erasure-code large_file.mp4 --chunk-size 5242880 # 5MB chunks
386
+ ```
306
387
 
307
388
  ## Command Line Interface
308
389
 
@@ -315,7 +396,7 @@ The Hippius SDK includes a powerful command-line interface (CLI) that provides a
315
396
  hippius --help
316
397
 
317
398
  # Set global options
318
- hippius --gateway https://ipfs.io --api-url https://relay-fr.hippius.network --verbose
399
+ hippius --gateway https://ipfs.io --api-url https://store.hippius.network --verbose
319
400
  ```
320
401
 
321
402
  ### IPFS Operations
@@ -400,7 +481,7 @@ hippius ec-files --all-miners
400
481
  hippius ec-files --show-chunks
401
482
  ```
402
483
 
403
- 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.
484
+ The `ec-files` command has been optimized for performance and can now handle large numbers of files efficiently through parallel processing.
404
485
 
405
486
  ### Using Environment Variables
406
487
 
@@ -408,7 +489,7 @@ The CLI automatically reads from your `.env` file for common settings:
408
489
 
409
490
  ```
410
491
  IPFS_GATEWAY=https://ipfs.io
411
- IPFS_API_URL=https://relay-fr.hippius.network
492
+ IPFS_API_URL=https://store.hippius.network
412
493
  SUBSTRATE_URL=wss://rpc.hippius.network
413
494
  SUBSTRATE_SEED_PHRASE="your twelve word seed phrase..."
414
495
  SUBSTRATE_DEFAULT_MINERS=miner1,miner2,miner3
@@ -515,13 +596,14 @@ The configuration is organized in the following sections:
515
596
  {
516
597
  "ipfs": {
517
598
  "gateway": "https://ipfs.io",
518
- "api_url": "https://relay-fr.hippius.network",
599
+ "api_url": "https://store.hippius.network",
519
600
  "local_ipfs": false
520
601
  },
521
602
  "substrate": {
522
603
  "url": "wss://rpc.hippius.network",
523
604
  "seed_phrase": null,
524
- "default_miners": []
605
+ "default_miners": [],
606
+ "default_address": null
525
607
  },
526
608
  "encryption": {
527
609
  "encrypt_by_default": false,
@@ -706,7 +788,13 @@ hippius --help
706
788
  which hippius
707
789
  ```
708
790
 
709
- 4. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
791
+ 4. **Default Address Issues**: If you receive errors about missing account address:
792
+ ```bash
793
+ # Set a default address for read-only operations
794
+ hippius address set-default 5H1QBRF7T7dgKwzVGCgS4wioudvMRf9K4NEDzfuKLnuyBNzH
795
+ ```
796
+
797
+ 5. **Substrate Issues**: For marketplace operations, make sure your `.env` has the correct `SUBSTRATE_SEED_PHRASE` and `SUBSTRATE_URL` values.
710
798
 
711
799
  ## Contributing
712
800
 
@@ -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",
@@ -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
@@ -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": {
@@ -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
@@ -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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "hippius"
3
- version = "0.1.7"
3
+ version = "0.1.9"
4
4
  description = "Python SDK and CLI for Hippius blockchain storage"
5
5
  authors = ["Dubs <dubs@dubs.rs>"]
6
6
  readme = "README.md"
File without changes