Introduction
Komodo’s lead developer/founder James Lee “jl777” recently started working on an exciting new tech to scale atomicDEX orderbook called “dexp2p”. This will work as realtime decentralised p2p orderbook and millions of orders can be displayed without clogging down the p2p network. While this is a great solution for atomicDEX orderbook, it opens door for many new possibilities. One of them is live streaming of video or any other files.
This live streaming works pretty well as it was developed in the last few days. On my testing, I used one computer with one of TechLoverHD’s YouTube video in a loop with OBS Studio software to record as stream. This way the file grows as time passes and gets uploaded to the p2p network while another computer subscribes to that stream. That enables the files to be downloaded as more parts are being uploaded at the same time and the file can be played with VLC or any other compatible player.
Important Notes of DEXP2P
- This technology is still being developed.
- There is 1GB file size limit.
- If you run into any issues, found a bug or have any suggestions, please join Komodo Discord and post in #ask-jl777 channel.
- This guide is written for Linux (Debian/Ubuntu) users in mind. If you want to use macOS or Windows, you need to adapt the compile, launch param for your specific OS. Need help on those OS please check the last point above.
- Make sure you have enough data/bandwidth in your plan. If you are using limited mobile data, you might not want to stream as this may use up a lot of your allowance. For small file sharing is ok.
- All files gets purged after one hour.
Compile Komodo and Launch the DEXP2P Test Chain
You need to compile Komodo (currently on DEX
branch) from jl777’s repo and launch the test chain DEXP2P with the specific param -dexp2p
to enable this new tech.
Install Dependencies
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libgtest-dev libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate software-properties-common curl clang libcurl4-gnutls-dev cmake clang libsodium-dev -y
Clone & Compile
git clone https://github.com/jl777/komodo
cd komodo
git checkout DEX
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)
Launch DEXP2P Chain
~/komodo/src/komodod -ac_name=DEXP2P -dexp2p=2 -ac_supply=999999 -addnode=37.9.62.186 -addnode=94.130.224.11 &
After launching the DEXP2P chain, you might want to generate a new address with getnewaddress
and use validateaddress <ADDRESS>
to get the pubkey
of your address to launch daemon with your pubkey next time. Alternatively, you can use setpubkey
command to set the pubkey without restarting daemon. If you chose to restart daemon with your pubkey that you got from validateaddress
RPC command, you should use the chain param like this ~/komodo/src/komodod -ac_name=DEXP2P -dexp2p=2 -ac_supply=999999 -pubkey=<YOUR_PUBKEY> -addnode=37.9.62.186 -addnode=94.130.224.11 &
.
Note: If you don’t use pubkey for dexp2p
chains, it will assign you a random pubkey on each start to use with dexp2p. dexp2p
pubkey33 hash looks like this 01132087a751dcfc797611496fda28f91e194f0fbc9bd57a06d6ba9f15934c682a
which starts with 01
.
Broadcast Your Stream
There are two types of stream you can broadcast/upload. One of them is just a video. Another one is Live Stream. You can live stream basically any file that grows over time. For video Live stream you need an additional software (i.e.: OBS Studio) which can take input from different source and record the stream into a file where the file size grows and you broadcast it. We will explain both method below.
Broadcast a normal file
Make sure you have the file inside ~/komodo/src/
directory which you want to upload/broadcast. You can boardcast any file type you like. Then, use the following command to upload it. We are using a file name called mkv1.mkv
in this following example.
Usage: DEX_publish filename priority rescan
Example: ./komodo-cli -ac_name=DEXP2P DEX_publish mkv1.mkv 0 1
The above command will generate output like below with results.
{
"fname": "mkv1.mkv",
"id": 3057049824,
"senderpub": "01132087a751dcfc797611496fda28f91e194f0fbc9bd57a06d6ba9f15934c682a",
"filesize": 4820415,
"fragments": 483,
"numlocators": 483,
"filehash": "ab100868752b84c6e0ae55b347ef72156439e6632fe387faa9ac7b04c6302d2b",
"result": "success"
}
Method for retrieving the file is described in the following section after next one.
Broadcast a Live Stream
To live stream a file, we need have a file that is continuously growing and need to use the above command in a while do
loop for continuous upload. For this section, we need an additional software called OBS Studio to create a file that keeps increasing in size.
Once you have OBS Studio installed, head over to settings as we need to make some changes there.
- Select
mkv
from Settings > Output > Recording > Recording Format > mkv - Set recording path to your
~/komodo/src/
directory - Tick Generate Filename without Space
- Under Advanced section on settings change the Filename Formatting to make them under 15 chars. (example image below)
The screenshot above shows the filename will be generated with hour-minute-second before the extension. You customize it as your liking but please keep it short.
Once you start streaming, you should see a file generated inside your ~/komodo/src
directory which we will stream continuously as the filesize increases. To do this, we need a script. The following script uses 16-26-52.mkv
as filename.
while true
do
./komodo-cli -ac_name=DEXP2P DEX_publish 16-26-52.mkv 0 1
sleep 5
done
Make sure you have used chmod +x
on your script to make it executable and just issue it. This should start printing outputs as fragments of files being uploaded via dexp2p system.
Retrieve a File or Subscribe to a Live Stream
You can retrieve a file easily with a single command. For subscribing and watching a live stream using dexp2p tech you need to run that command in a while do
loop continuously as long as you want to watch the stream. To watch live streams, you might want to get VLC player for your OS. In Ubuntu, the default video player just works fine. Both methods are described below.
Retrieve a File
To retrieve a file, you need to know the name of the file and publisher’s pubkey33 bit which starts with 01
. Use the following command to retrieve the file.
Usage: DEX_subscribe filename priority id [publisher33]
./komodo-cli -ac_name=DEXP2P DEX_subscribe 09-38-08.mkv 0 0 01e24167092387c1dee4899be586c4f092ad6cad91cf086dc842f1940c9c000e62
You should see some results in the output showing success if the file is available. (all files gets purged after 1 hour). You can find the file downloaded inside your ~/komodo/src/
directory. The filename will contain the pubkey33 id of the publisher after the file extension. In case for this example the filename will be 09-38-08.mkv.01e24167092387c1dee4899be586c4f092ad6cad91cf086dc842f1940c9c000e62
Subscribe to Live-Stream and Watch
To watch a live stream of video or any log file, you need to have the same info as the last step, which are file name and publisher’s pubkey33 bit. Basically the above command in a loop. Assuming we will stream the same file as above and watch it in VLC, we just need to put the same RPC command in a while do
script. Below is the example of the script and make sure you used chmod +x
to make the script executable and put it inside ~/komodo/src/
dir.
while true
do
./komodo-cli -ac_name=DEXP2P DEX_subscribe 09-38-08.mkv 0 0 01e24167092387c1dee4899be586c4f092ad6cad91cf086dc842f1940c9c000e62
sleep 5
done
When you run the script, it will start and keep pulling the fragments of the file as it grows and available in the network. You will find a video file named 09-38-08.mkv.01e24167092387c1dee4899be586c4f092ad6cad91cf086dc842f1940c9c000e62
inside the src
directory. You can use Ubuntu’s default media player or VLC to play the file.
Conclusion
The tech is still being developed actively and evolving pretty fast. Please always make sure to use git pull
and build the latest source before testing as old code might have bugs or limitation which are fixed in the latest source. As of it’s current state, the dexp2p
tech is working very well and seems pretty promising.
If you find this article helpful please show us some love by sharing it with your friends. You can also donate any KMD or smartchain at this address RG839yyK53NSJMsVURNZm95YkVpjYxNoob
to help us keep going. Thank you!