Skip to main content

Decentralized computer network

Project description

Node

github | dockerhub

Client

github | pypi

Setup guide

Using PyPi

Linux and MacOS

pip3 install dcn

Windows

pip install dcn

Using github

Linux and MacOS

git clone https://github.com/draklowell/DCNLibrary && cd DCNLibrary && python3 setup.py install

Windows

Download client and in downloaded folder run

python setup.py install

Dependencies

  1. requests ( 2.22.0 )
  2. pycryptodome ( 3.9.9 )

Info

Privacy

Connection between two nodes is wrapped by TLSv1.2 ( without certificate verification ), but packet is opened, and can be read by any user.

High-level protocols conflict

To avoid protocol conflicts, we recommend to use protocol sign, it is some bytes in begin of packet, that indicate what protocol is using

License

Apache License 2.0

Using guide

Packet format

2 BYTES - Size of packet
16 BYTES - Custom UUID
65520 BYTES - Content

Max size of content in packet - 65520 ( pow(2, 16) - 16 ).

Create client

There are two arguments - friendly_hosts and limit_queue

friendly_hosts - known nodes in format ( example: ("1.2.3.4", 300) ), also it request official nodes, from official tracker

limit_queue - max size of queue ( -1 - unlimited ), recommended 65536

import dnc
client = dnc.client.Client(friendly_hosts = [], limit_queue = -1)

Send packet

After generating packet, client sends it to all known nodes. After that, it returns the count of successfully sent copies of the packet and packet hash ( as bytes )

import base64
count, hash = client.send(b"Hello, world!")
print(f"Sended copies of packet: {count}")
print(f"Packet hash ( base64 encoded ): {base64.b64encode(hash).decode()}")

Output:

Sended copies of packet: 1
Packet hash ( base64 encoded ): oZ/dl88Jbb2CiCCQadpxeQSU/HVpHN3k6A+jAIT8G4k=

Receive next packet

When the client gets the new massage from the node, client adds the packet to the queue. When we call client.accept(), we get the first element of the queue, and then remove it ( we can limit the queue, while initializing client )

import base64
content, hash = client.accept() # or client.next() or next(client)
print(f"Content of packet: {content.decode()}")
print(f"Packet hash ( base64 encoded ): {base64.b64encode(hash).decode()}")

Output:

Content of packet: Hello world!
Packet hash ( base64 encoded ): oZ/dl88Jbb2CiCCQadpxeQSU/HVpHN3k6A+jAIT8G4k=

Close client

You need close client in end of work

client.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dcn-2.0.0.4.2.linux-x86_64.tar.gz (8.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page