Python implementation of a kaspa grpc client
Project description
kaspy
Python implementation of a kaspa-grpc client.
work in progress...
Breaking changes will occur without prior notice!
Installaton:
pip install kaspy
Basic Documentaion:
Connecting to a RPC server with connect() or auto_connect():
# Import the kaspa client
from kaspy.kaspa_clients import RPCClient
#Initialize a client instance
client = RPCClient()
#Connect to a predefined host
client.connect(host='<ip>', port='<port>')
#OR
#Connect to a a publicaly broadcasted node from the dns_seed_servers.
client.auto_connect() #note: it may take a while to find a responsive nodes, timeout should be issued to not get stuck searching
Sending a request():
continued...
#define the command you want to send
command = 'getInfoRequest'
#build the payload for the command
payload = {} #in our case we don't need to send additional information
#send the request to the server and retrive the response
resp = client.request(command=command, payload=payload)
print(resp) # print response
Subscribing to a stream with subscribe():
continued...
command = 'notifyVirtualSelectedParentChainChangedRequest'
payload = {}
def callback_func(notification : dict) # create a callback function to process the notifications
print(notification)
#send the request to the server and retrive the response
resp = client.subscribe(command=command, payload=payload, callback=callback_func)
import time
time.sleep(5) # do stuff
client.unsubscribe(command) #unsubscribe to the stream
Disenganging the service with close() or disconnect()
continued...
client.disconnect() # finishes sending all requests and responses in Que, halts all operations, but keeps the channel open.
client.close() # closes the channel completely
for more references on commands and payloads see:
for conversions to KaspaMessage command names reference:
https://github.com/kaspagang/kaspy/blob/master/kaspy/protos/messages.proto
known issues:
GLIBC_2.33' not found: https://github.com/kaspagang/kaspy/issues/4 [Workaround]
To Do:
Fix breaking issue
Clean up, lots of unused code left in place.
Implement error handling and timeouts
Implement Streaming Callback handling of notification messages
add to pip
Implement auto-reconnect options to client
- Implement P2P communication
- 2nd cleanup
- Documentation
- Allow for commandline use
- ...
- Async Implementation
Requirements
- grpc
Contribute
feel free to open a pull request.
Authors
Donations welcome @ kaspa:qzyjckdvgyxgwqj8zztw7qkqylsp864fyquzg8ykmmwkz58snu85zlk0mfy89
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kaspy-0.0.6-py3-none-any.whl.
File metadata
- Download URL: kaspy-0.0.6-py3-none-any.whl
- Upload date:
- Size: 56.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e8523dc50aca861c480194919b7a6e83fe5a3e328db0feea1fa0a9f43d9e50a
|
|
| MD5 |
902c7b3a9a1eeb6b43ca26184e7fffb2
|
|
| BLAKE2b-256 |
87886f875a9a072e9c79f2c8341243c041c7e9ff06c01890c5d0a4fa3fd721af
|