Skip to content

Conversation

@SpudGunMan
Copy link

Summary

  • Added a new method get_channels_with_hash() to the Node class.
  • This method returns a list of dictionaries, each containing the channel index, role, name, and a hash value derived from the channel name and PSK.
  • The hash is calculated using the existing generate_hash utility, ensuring consistency with other parts of the codebase.
  • This utility makes it easier to programmatically access channel metadata, including a unique hash, for scripting, debugging, or integration purposes.

Motivation

  • The protobuf Channel objects do not include a hash value by default.
  • This addition provides a Pythonic, easy-to-use way to access channel info and a unique hash for each channel, which can be useful for diagnostics, scripting, or UI display.

Example Usage

channels = node.get_channels_with_hash()
for ch in channels:
    print(f"Index {ch['index']}: {ch['role']} name='{ch['name']}' hash={ch['hash']}")

Impact

  • No breaking changes; existing APIs and CLI output remain unchanged.
  • The new method is additive and can be used where needed for enhanced channel introspection.

### Summary

- Added a new method `get_channels_with_hash()` to the `Node` class.
- This method returns a list of dictionaries, each containing the channel index, role, name, and a hash value derived from the channel name and PSK.
- The hash is calculated using the existing `generate_hash` utility, ensuring consistency with other parts of the codebase.
- This utility makes it easier to programmatically access channel metadata, including a unique hash, for scripting, debugging, or integration purposes.

### Motivation

- The protobuf `Channel` objects do not include a hash value by default.
- This addition provides a Pythonic, easy-to-use way to access channel info and a unique hash for each channel, which can be useful for diagnostics, scripting, or UI display.

### Example Usage

```python
channels = node.get_channels_with_hash()
for ch in channels:
    print(f"Index {ch['index']}: {ch['role']} name='{ch['name']}' hash={ch['hash']}")
```

### Impact

- No breaking changes; existing APIs and CLI output remain unchanged.
- The new method is additive and can be used where needed for enhanced channel introspection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant