Enhanced Peer to Peer data broadcast and synchronisation between Nodes of a Smart Chain
This Peer to Peer Messaging Enhancement technology is in development. The specifics of the implementation are subject to change. This document is a Work In Progress.
All the nodes of a Smart Chain started with the Optional parameter -dexp2p
(set to 1
or 2
) start listening and propagating data packets broadcasted by other nodes on the network. These data packets don't necessarily contain the Smart Chain's transactions, are stored in a node's RAM and dropped after 1 hour.
Let's call this local data stored as "Data Mempool" as opposed to the "Mempool/Transaction Mempool" that stores just the unconfirmed transactions of the Smart Chain. The data is transmitted from from one node to another in the form of "datablobs". A "datablob" contains the timestamp, the data itself (encrypted if a destination pubkey is provided, see: DEX_broadcast), a nonce, the SHA256 hash of the payload and other metadata.
- if
-dexp2p=1
is used, the node will participate in the p2p data network but doesn't respond to requests from nSPV superlight clients - if
-dexp2p=2
is used, the node will participate in the p2p data network and also responds to requests from nSPV superlight clients
This p2p data transmission and synchronisation layer can be used for any generic data. But, there are certain enhancements made to the RPC that enable the usage of this layer as a Decentralised, Peer to Peer order broadcasting mechanism for the Komodo DeFi Framework API
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 python-zmq zlib1g-dev wget curl bsdmainutils automake cmake clang libsodium-dev libcurl4-gnutls-dev libssl-dev git unzip python jq htop -y
git clone https://github.com/jl777/komodo -b jl777 --single-branch
cd komodo
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)
Currently, this technology is being tested on a test chain named DORN
Launch Parameters:
./komodod -ac_name=DORN -ac_cc=2 -ac_supply=1000000 -ac_reward=100000000 -addnode=136.243.58.134 -dexp2p=2
You might want to add the parameter -pubkey
with the value as your pubkey for convenient testing of encrypted "datablobs" across multiple daemon restarts
After the initial output common to all the daemons is printed, a daemon started with the -dexp2p=2
command starts printing statistics about the datablobs it has seen and the state of the dexp2p
network from its perspective. Most of the stats from the daemon output can also be accessed through the DEX_stats RPC
Example:
2040: del.0 00000000, RAM.207 84b824a6 R.0 S.621 A.621 dup.0 | L.0 A.0 coll.0 | lag 0.000 (0.0000 0.0000 0.0000) err.0 pend.0 T/F 414/414 | 0 0 0 0 0 0 1 1 6 4 10 31 46 108 3/sec
2040
is the time in seconds since the last purge of the datablobs stored in the node's RAM; calculated asunixtimestamp % purgetime
;%
means modulo and the default purge time is1 hour
del.0
means0
datablobs were purged by the node in the last minute00000000
is the checksum of the purged datablobs in the last second (for performance reasons)RAM.207
means there are currently207
datablobs in the node's RAM84b824a6
is the checksum of all the datablobs in the RAMR.0 S.621 A.621
means the node Received0
messages, Sent621
messages, Added621
messages; there are no right or wrongR
andS
values; ideally, all the nodes that don't publish/stream should have the same R and S values; but, some nodes may have largerS
values thanR
based on connectivity, network topology and which datablobs its peers already havedup.0
means the node received0
duplicate datablobs; high amount of duplicates is bad as it wastes bandwidthL.0 A.0 coll.0
these are some stats for internal tracking/debugging and should not be relevant to a user/developerlag 0.000 (0.0000 0.0000 0.0000)
in this string, the number right beside the wordlag
is the average lag over different windows of datablobs. The numbers in the brackets denote the actual lags in the different windows. The different windows are:fast window
,medium window
,long window
which mean the most recent1000
,10000
,100000
datablobs respectively; there might be huge values of lag recorded within thefirst minute
of starting the node as VIP datablobs from other nodes start arriving even though they weren't published recentlyerr.0
means0
non-VIP datablobs were received with over1 minute
lagpend.0
means there are0
pending datablobs to be received from the networkT/F 414/414
means414
datablobs were purged by the node the the datablobs are firstTruncated
and then their memoryFreed
; this number together with the value ofRAM
(number of datablobs currently inRAM
) can be treated as the total number of datablobs processed by the node since its launch0 0 0 0 0 0 1 1 6 4 10 31 46 108
these numbers are the total number of datablobs in the node's RAM classified by their priority; the rightmost number gives the total number of datablobs with priority0
, the one left to it gives the total number of datablobs with priority1
and so on.... ; the left most number gives the total number of datablobs with priority greater than13
3/sec
is the number of datablobs per second for the last minute
DEX_anonsend message priority destpub33
This method can be used by a user to broadcast any message to the p2p network without revealing either the DEX_pubkey
s involved or the contents of the message to the network. The datablob so created will be added to the "Data Mempools" of all the nodes with the parameter -dexp2p
set to 1
or 2
, but can only be decrypted by the node whose DEX_pubkey
is destpub33
. The recipient node can also see the DEX_pubkey
of the sender.
This is achieved by first encrypting the message to the DEX_pubkey
: destpub33
and then encrypting it again using a publicly known key pair. This makes it so that, the datablob looks the same regardless who sent it, and only the node with DEX_pubkey
set to destpub33
will be able to decrypt it.
Note that, an attacker with large resources will be able to tell the ip address of the node which published the data packet and if the node publishes other datablobs that reveal its DEX_pubkey
, thereby linking them. But, it is not possible for the uninvolved to know who the intended recipient is.
Name | Type | Description |
---|---|---|
message | (string) | the message to be sent |
priority | (number) | the priority with which the anonymous message has to be sent |
destpub33 | (string) | the DEX_pubkey of the recipient node |
Name | Type | Description |
---|---|---|
timestamp | (number) | UNIX timestamp at which the datablob was created |
id | (number) | short hash of the datablob; can be treated as a unique id most of the time |
hash | (string) | hash of the datablob |
tagA | (string) | tagA of the datablob; is set to the value "anon" |
tagB | (string) | tagB of the datablob; is empty for this datablob |
pubkey | (string) | the public DEX_pubkey that was used to authenticate the datablob |
payload | (string) | all the data being sent in the datablob; contains the data,tags,volumes etc., |
hex | (boolean) | whether the payload is in hexadecimal format |
decrypted | (number) | the decrypted payload; |
decryptedhex | (number) | whether the decrypted payload is in hexadecimal format; 0 when false and 1 when true ; |
senderpub | (string) | the actual DEX_pubkey of the sender |
amountA | (string) | amount associated with tagA (volumeA) |
amountB | (string) | amount associated with tagB (volumeB) |
priority | (number) | the priority with which the datablob will be routed by the network |
recvtime | (number) | the unix timestamp at which the datablob was first observed by the node |
cancelled | (number) | whether the datablob is set to be purged prematurely; in the context of Komodo DeFi Framework orders, it means the order has been cancelled; 0 when false and 1 when true |
./komodo-cli -ac_name=DORN DEX_anonsend "hello" 6 012767b0e6d680cf65b1993ddb4ccbb7f1acd027a04ed93c0b06f97714284e214d
The receiving node can find all the messages sent to it through the DEX_anonsend method by using the method DEX_list for listing all the the datablobs with tagA
set to "anon"
and looking for the matches that have the keys "anonmsg"
and "anonsender"
in them.
./komodo-cli -ac_name=DORN DEX_list "" 0 "anon" "" "" "" ""
DEX_broadcast hex [priority [tagA [tagB [pubkey33 [volA [volB]]]]]]
This method can be used to broadcast any data to the p2p network, which will be added to the "Data Mempools" of all the nodes with the parameter -dexp2p
set to 1
or 2
.
Name | Type | Description |
---|---|---|
hex | (string) | the data to be broadcasted; can be in hex format or ASCII; to specify that the string has to be parsed as ASCII, surround it with quotes the size limit of a "datablob" is 1MB; the size of the actual data to be broadcasted is recommended to be smaller than 1MB to combat spam, after the size of "datablob" crosses 1KB, each time the size doubles, its priority is reduced by 1; this will make generating valid packets for larger data more and more expensive as not only is the difficulty increased by the packetsize, the amount of data to be hashed is increasing too |
priority | (string, optional) | the priority with which other nodes will route the data; can be an integer between 0 to 16 increasing the priority of a data broadcast increases the time taken by a CPU to create it; this is achieved by changing a "nonce" in the "datablob" until the lowest bits of the SHA256 hash match 011101110111 (0x777 ) and each of the next "priority" number of bits to 0 Example: if priority is set to 5 , the lowest bits of the hash will be 01110111011100000 |
tagA | (string, optional) | the first tag to be associated with the data; an index associated to a tag is created in the RAM of a node and is used for quick data lookups; limited to 15 characters ;in the context of a Komodo DeFi Framework order, tagA is the "base" (maker) coin being traded; if all the three values: tagA , tagB and pubkey33 are set to "" ie., unspecified, tagA defaults to the value "general"; if tagA is set to "inbox" , then the data is encrypted to the destination pubkey set using the pubkey33 parameter ; all the other nodes on the network can propagate the data; but, only the node that owns the destination pubkey is able to decrypt it; if tagA is not set to "inbox", the data is encrypted to a publicly known keypair so that the sender pubkey can be authenticated |
tagB | (string, optional) | the second tag to be associated with the data; an index associated to a tag is created in the RAM of a node and is used for quick data lookups; limited to 15 characters; in the context of a Komodo DeFi Framework order, tagB is the "rel" (taker) coin being traded |
pubkey33 | (string, optional) | the pubkey which is associated with the datablob, called the DEX_pubkey ; this is not a regular pubkey that starts with 02 or 03 , it starts with 01 ; it can be found from the output of the DEX_stats RPC; it is also printed in the STDOUT of the komodod in a line that starts with DEX_pubkey.( if the node is started with the -pubkey parameter using a regular pubkey owned by the node, its privatekey is used to create the corresponding DEX_pubkey and printed; else, a keypair is generated for the particular session and its privatekey is used to create the corresponding DEX_pubkey and printed if the tagA is set to "inbox", the datablob is encrypted to the DEX_pubkey specified by the pubkey33 parameter; if tagA is not set to "inbox", the datablob is authenticated by the DEX_pubkey provided through the pubkey33 parameter by encrypting it to a publicly known keypair; if tagA is not set to "inbox" and the parameter pubkey33 is set to "" , i.e., unspecified, the datablob is not authenticated by any DEX_pubkey and broadcasted to the network un-encrypted; |
volA | (float - 8 decimals, optional) | in the context of a Komodo DeFi Framework order, volume of the coin denoted by tagA |
volB | (float - 8 decimals, optional) | in the context of a Komodo DeFi Framework order, volume of the coin denoted by tagB |
Name | Type | Description |
---|---|---|
timestamp | (number) | UNIX timestamp at which the datablob was created |
id | (number) | short hash of the datablob; can be treated as a unique id most of the time |
hash | (string) | hash of the datablob; the payload is hashed like so: sha256(curve25519(sha256(payload))) , the curve25519 hash is included to make the process FPGA resistant to deter spammers; there are no known ASICS for it |
tagA | (string) | tagA of the datablob |
tagB | (string) | tagB of the datablob |
pubkey | (string) | the pubkey the payload is tagged with; if tagA is "inbox", the payload is encrypted and only the owner of the pubkey can decrypt the datablob |
payload | (string) | all the data being sent in the datablob; contains the data,tags,volumes etc., |
hex | (number) | whether the payload is in hexadecimal format; 0 when false and 1 when true |
decrypted | (number) | the decrypted payload; |
decryptedhex | (number) | whether the decrypted payload is in hexadecimal format; 0 when false and 1 when true ; |
error | (string) | errors if any |
senderpub | (string) | the DEX_pubkey of the sender |
amountA | (string) | amount associated with tagA (volumeA) |
amountB | (string) | amount associated with tagB (volumeB) |
priority | (number) | the priority with which the datablob will be routed by the network |
recvtime | (number) | the unix timestamp at which the datablob was first observed by the node |
cancelled | (number) | whether the datablob is set to be purged prematurely; in the context of Komodo DeFi Framework orders, it means the order has been cancelled; 0 when false and 1 when true |
./komodo-cli -ac_name=DORN DEX_broadcast "hello" 5 "BTC" "KMD" "01e28518858aa3515163a67deee2b19f0d30e4fa237f0aec255e4c94db0fe8d063" "0.1" "100"
DEX_cancel id [pubkey33 [tagA tagB]]
This method can be used to cancel an order issued by the user's node. A node can cancel only the orders that were broadcasted using its current DEX_pubkey
. Orders that are broadcasted without being authenticated by a pubkey can not be canceled.
Name | Type | Description |
---|---|---|
id | (number, optional) | short hash of the datablob; can be treated as a unique id most of the time |
pubkey33 | (string, optional) | the pubkey the payload is tagged with |
tagA | (string, optional) | tagA of the datablob |
tagB | (string, optional) | tagB of the datablob |
Name | Type | Description |
---|---|---|
timestamp | (number) | UNIX timestamp at which the datablob was created |
id | (number) | short hash of the datablob; can be treated as a unique id most of the time |
hash | (string) | hash of the datablob |
tagA | (string) | tagA of the datablob; it's value is "cancel" and it lets other nodes on the network |
tagB | (string) | tagB of the datablob |
pubkey | (string) | the pubkey the payload is tagged with; if tagA is "inbox", the payload is encrypted and only the owner of the pubkey can decrypt the datablob |
payload | (string) | all the data being sent in the datablob; contains the data,tags,volumes etc., |
hex | (number) | whether the payload is in hexadecimal format; 0 when false and 1 when true |
decrypted | (number) | the decrypted payload; when the byte order is reversed and converted to decimal, gives the id to be cancelled |
decryptedhex | (number) | whether the decrypted payload is in hexadecimal format; 0 when false and 1 when true ; |
error | (string) | errors if any |
senderpub | (string) | the DEX_pubkey of the sender |
amountA | (string) | amount associated with tagA (volumeA) |
amountB | (string) | amount associated with tagB (volumeB) |
priority | (number) | the priority with which the datablob will be routed by the network |
recvtime | (number) | the unix timestamp at which the datablob was first observed by the node |
cancelled | (number) | whether the datablob is set to be purged prematurely; in the context of Komodo DeFi Framework orders, it means the order has been cancelled; 0 when false and 1 when true |
Cancel an order by its "id"
./komodo-cli -ac_name=DORN DEX_cancel 2432811744
Cancel all orders tagged with a "pubkey"
./komodo-cli -ac_name=DORN DEX_cancel "" 01e28518858aa3515163a67deee2b19f0d30e4fa237f0aec255e4c94db0fe8d063
Cancel all orders published for a specific base/rel
pair
./komodo-cli -ac_name=DORN DEX_cancel "" "" "KMD" "BTC"
DEX_get id
This method returns an order's data by its id.
Name | Type | Description |
---|---|---|
id | (number) | short hash of the order |
Name | Type | Description |
---|---|---|
timestamp | (number) | UNIX timestamp at which the datablob was created |
id | (number) | short hash of the datablob; can be treated as a unique id most of the time |
hash | (string) | hash of the datablob |
tagA | (string) | tagA of the datablob |
tagB | (string) | tagB of the datablob |
pubkey | (string) | the pubkey the payload is tagged with; if tagA is "inbox", the payload is encrypted and only the owner of the pubkey can decrypt the datablob |
payload | (string) | all the data being sent in the datablob; contains the data,tags,volumes etc., |
hex | (number) | whether the payload is in hexadecimal format; 0 when false and 1 when true |
decrypted | (number) | the decrypted payload; |
decryptedhex | (number) | whether the decrypted payload is in hexadecimal format; 0 when false and 1 when true ; |
error | (string) | errors if any |
senderpub | (string) | the DEX_pubkey of the sender |
amountA | (string) | amount associated with tagA (volumeA) |
amountB | (string) | amount associated with tagB (volumeB) |
priority | (number) | the priority with which the datablob will be routed by the network |
recvtime | (number) | the unix timestamp at which the datablob was first observed by the node |
cancelled | (number) | whether the datablob is set to be purged prematurely; in the context of Komodo DeFi Framework orders, it means the order has been cancelled; 0 when false and 1 when true |
./komodo-cli -ac_name=DORN DEX_get 2122297120
DEX_list stopat minpriority tagA tagB pubkey33 [minA maxA minB maxB [stophash]]
This method can be used to filter and list data from the "Data Mempool" of the node. Each specified filter narrows the list down to the datablobs that match it exactly. If a filter is specified as ""
or 0
, it matches all the values a datablob might have for the filter.
Name | Type | Description |
---|---|---|
stopat | (string) | the id of the datablob until which the filtered list is to be displayed, excluding the datablob with the given id |
minpriority | (string) | the minimum priority of the datablobs to be filtered |
tagA | (string) | the value of tagA by which the available datablobs are filtered; if all the three values: tagA , tagB and pubkey33 are set to "" ie., unspecified, tagA defaults to the tag "general" |
tagB | (string) | the value of tagB by which the available datablobs are filtered |
pubkey33 | (string) | the value of destination publickey to filter the available datablobs |
minA | (float - 8 decimals, optional) | the minimum value of the amount associated to tagA to filter the available datablobs |
maxA | (float - 8 decimals, optional) | the maximum value of the amount associated to tagA to filter the available datablobs |
minB | (float - 8 decimals, optional) | the minimum value of the amount associated to tagB to filter the available datablobs |
maxB | (float - 8 decimals, optional) | the maximum value of the amount associated to tagB to filter the available datablobs |
stophash | (string, optional) | the hash of the datablob until which the filtered list is to be displayed excluding the datablob with the given hash ; taken into account only when stopat is set to "" or 0 |
How to use the DEX_list RPC periodically to filter the datablobs received by the node and get each datablob exactly once?
- call DEX_list with both
stopat
andstophash
set to""
and the rest of the filters as necessary - the response will contain all the available datablobs sorted in the order: "latest" to "oldest"
- let the
id
of the latest datablob(first one in the list) beid_1
and itshash
behash_1
- if we call DEX_list again with
stopat
set toid_1
andstophash
set to""
(rest of the filters are the same), the response will contain all the newer datablobs till the datablob that has theid
equal toid_1
(excluding it) - alternatively, if we call DEX_list with stopat set to
""
andstophash
set tohash_1
(rest of the filters are the same), the response will contain all the newer datablobs till the datablob that has thehash
set tohash_1
(excluding it)
Name | Type | Description |
---|---|---|
matches | (array of json) | an array containing json representations of the matched datablobs |
timestamp | (number) | UNIX timestamp at which the datablob was created |
id | (number) | short hash of the datablob; can be treated as a unique id most of the time |
hash | (string) | hash of the datablob |
tagA | (string) | tagA of the datablob |
tagB | (string) | tagB of the datablob |
destpub | (string) | the destpubkey to which the payload is encrypted to |
payload | (string) | all the data being sent in the datablob; contains the data,tags,volumes etc., |
hex | (boolean) | whether the payload is in hexadecimal format |
decrypted | (number) | the decrypted payload; |
decryptedhex | (number) | whether the decrypted payload is in hexadecimal format; 0 when false and 1 when true ; |
anonmsg | (string) | the decrypted anonymous message received by the node from a anonsender who most likely used the DEX_anonsend method |
anonsender | (string) | the DEX_pubkey of the anon message sender |
error | (string) | errors if any; the error says "wrong sender" if the actual DEX_pubkey of the sender is different from the claimed one |
senderpub | (string) | the actual DEX_pubkey of the sender |
amountA | (string) | amount associated with tagA (volumeA) |
amountB | (string) | amount associated with tagB (volumeB) |
priority | (number) | the priority with which the datablob will be routed by the network |
recvtime | (number) | the unix timestamp at which the datablob was first observed by the node |
cancelled | (number) | whether the datablob is set to be purged prematurely; in the context of Komodo DeFi Framework orders, it means the order has been cancelled; 0 when false and 1 when true |
tagA | (string) | the tagA used to filter |
tagB | (string) | the tagB used to filter |
pubkey | (string) | the pubkey used to filter |
n | (integer) | number of matches |
./komodo-cli -ac_name=DORN DEX_list "" 0 "BTC" "" "" "" "" "" "" ""
DEX_orderbook maxentries minpriority tagA tagB pubkey33 [minA maxA minB maxB]
This method interprets the datablobs as orders for Komodo DeFi Framework and displays relevant data for each order that matches the filters applied through the parameters.
Name | Type | Description |
---|---|---|
maxentries | (string) | the maximum number of orders to list |
minpriority | (string) | the minimum priority of the orders to be listed |
tagA | (string) | the value of tagA by which the available orders are filtered; this tag is treated as the "base" coin's name |
tagB | (string) | the value of tagB by which the available orders are filtered ; this tag is treated as the "rel" coin's name |
pubkey33 | (string) | the value of public key to filter the available orders |
minA | (float - 8 decimals, optional) | the minimum volume of the coin named by tagA to filter the available orders |
maxA | (float - 8 decimals, optional) | the maximum volume of the coin named by tagA to filter the available orders |
minB | (float - 8 decimals, optional) | the minimum volume of the coin named by tagB to filter the available orders |
maxB | (float - 8 decimals, optional) | the maximum volume of the coin named by tagB to filter the available orders |
Name | Type | Description |
---|---|---|
asks | (array of json) | all the asks for the base coin named by tagA w.r.t to the rel coin named by tagB |
price | (string) | the price offered; calculated as amountB/amountA of the datablob |
baseamount | (string) | the volume of the base coin offered; amountA of the datablob |
relamount | (string) | the volume of the base coin offered; amountB of the datablob |
priority | (number) | the priority of the order |
pubkey | (string) | the pubkey associated with the order |
timestamp | (number) | the timestamp of the order |
hash | (number) | the hash of the order |
id | (number) | the short hash of the order ; can be treated as an unique id |
bids | (array of json) | all the bids for the base coin named by tagB w.r.t to the rel coin named by tagA |
price | (number) | the price offered; calculated as amountB/amountA of the datablob |
baseamount | (number) | the volume of the base coin offered; amountB of the datablob |
relamount | (number) | the volume of the base coin offered; amountA of the datablob |
priority | (number) | the priority of the order |
pubkey | (number) | the pubkey associated with the order |
timestamp | (number) | the timestamp of the order |
hash | (number) | the hash of the order |
id | (number) | the short hash of the order; can be treated as an unique id |
./komodo-cli -ac_name=DORN DEX_orderbook 10 0 KMD BTC
DEX_publish filename priority sliceid
This method allows a user to publish a file to the p2p Data Network. The file is broken into fragments and broadcast to the network using the datablobs. Take a look at the response of DEX_broadcast for a list of all the keys available in a datablob.
-
we recommend to publishing only one file at a time
-
there is a detailed explanation on how publishing and subscribing works here
-
it is also recommended to not issue the
stop
command to the daemon while a file is being published; doing so will make the daemon stop receiving further RPC, but it continues to publish the datablobs containing the data of the file; once that is done, the daemon shuts down; note that, the daemon publishes neither the datablob withtagA
set tofiles
andtagB
set to the file name nor thelocators
datblob, which results in no other node able to use the DEX_subscribe RPC to construct the file
Name | Type | Description |
---|---|---|
filename | (string) | the name of the file to be published; the name must be less than 15 characters long; the file must be present in the working directory from which the command to start the Komodo daemon(komodod ) was issued; not to be confused with the directory in which komodod is present; if the file is not found in the working directory, it is then searched in the user's ~/dexp2p directory and /usr/local/dexp2p directory in Linux/MacOS and in %APPDATA%\dexp2p in Windows |
priority | (number) | the minimum priority to be used for the broadcasted datablobs that contain the file's data; set this value above the VIP_PRIORITY level for prioritised transmission of the datablobs; for the VIP_PRIORITY being used by your node, see the value of vip in the response to the DEX_stats RPC |
sliceid | (number) | if set to 0 , it publishes the file; if set to 0 and the file is already published, it scans the datablobs present in the "Data mempool" and republishes the missing ones; if the value is an integer greater than 0 , it is the id of the slice to publish; this method treats the file as a number of 1 MB sized slices and publishs only the mentioned slice of the file; this functionality is used by the DEX_stream method |
Name | Type | Description |
---|---|---|
fname | (string) | the name of the file |
id | (number) | the id of the published file's locators datablob |
senderpub | (string) | the DEX_pubkey of the file's sender |
filesize | (number) | the size of the file in bytes |
fragments | (number) | the number of fragments the file has been broken down into; each fragment has a maximum size of 10000 byte |
numlocators | (number) | the number of locators of the published file |
filehash | (string) | the SHA256 hash of the file as indicated by the publishing node |
checkhash | (string) | the SHA256 hash of the file based on all the fragments the node has currently available |
result | (string) | whether the command was successfully executed |
./komodo-cli -ac_name=DORN DEX_publish roadmap2020.pdf 0
DEX_setpubkey pubkey33
This method allows a user set the DEX_pubkey
used by the node. Can only be used once per daemon start. It can't be used to change the pubkey that has already been set using the -pubkey
launch parameter.
If this method is used with a pubkey not owned by the node, the datablobs created/broadcast by this node can't be authenticated by the other nodes and can cause unpredictable behavior.
Name | Type | Description |
---|---|---|
pubkey33 | (string) | a regular pubkey to be used to create the DEX_pubkey ; recommended to use a pubkey of an address owned by the node |
Name | Type | Description |
---|---|---|
result | (string) | whether the command was successfully executed |
publishable_pubkey | (string) | the pubkey to be shared with another user for receiving encrypted data packets |
secpkey | (string) | the regular pubkey to be shared with another user for receiving encrypted data packets |
recvaddr | (string) | the regular public address associated with the secpkey ; this will be the R-address used for a subatomic swap |
recvZaddr | (string) | the value of the launch parameter -recvZaddr used when launching the node; it is the z-address of Pirate in the context of subatomic swaps |
handle | (string) | the value of the launch parameter -handle used when launching the node; it is the "username" associated with the node in the context of subatomic swaps |
txpowbits | (number) | the default number bits being used for txpow; the higher this value, the more resource intensive it is to send spam transactions |
vip | (number) | the minimum number of txpow bits to be present in a datablob for it to be considered a VIP; VIP datablobs are prioritised for routing by all nodes on the dexp2p network; if a node notices its peer not having a VIP datablob it knows about, it will ping the peer about it even if the VIP datablob was received by it a long time before then; this property is useful for helping newer nodes bootstrap important datablobls in saturated networks |
cmdpriority | (number) | the number of txpow bits being used for datablobs generated by commands; Example: DEX_cancel |
perfstats | (string) | a string containing stats about the datablobs and the "Data mempool" the local node is seeing |
./komodo-cli -ac_name=DORN DEX_setpubkey 03ac42ded82688c381563d2e123a2eaf54b29d9fd15a8bd4f9f2727dbfe9be1688
DEX_stats
This method gives info and stats related to the p2p data layer.
Name | Type | Description |
---|---|---|
(none) |
Name | Type | Description |
---|---|---|
result | (string) | whether the command was successfully executed |
publishable_pubkey | (string) | the pubkey to be shared with another user for receiving encrypted data packets |
secpkey | (string) | the regular pubkey to be shared with another user for receiving encrypted data packets |
recvaddr | (string) | the regular public address associated with the secpkey ; this will be the R-address used for a subatomic swap |
recvZaddr | (string) | the value of the launch parameter -recvZaddr used when launching the node; it is the z-address of Pirate in the context of subatomic swaps |
handle | (string) | the value of the launch parameter -handle used when launching the node; it is the "username" associated with the node in the context of subatomic swaps |
txpowbits | (number) | the default number bits being used for txpow; the higher this value, the more resource intensive it is to send spam transactions |
progress | (number) | the percentage of datablobs already broadcast when a single file is being published using the DEX_publish RPC |
vip | (number) | the minimum number of txpow bits to be present in a datablob for it to be considered a VIP; VIP datablobs are prioritised for routing by all nodes on the dexp2p network; if a node notices its peer not having a VIP datablob it knows about, it will ping the peer about it even if the VIP datablob was received by it a long time before then; this property is useful for helping newer nodes bootstrap important datablobls in saturated networks |
cmdpriority | (number) | the number of txpow bits being used for datablobs generated by commands; Example: DEX_cancel |
perfstats | (string) | a string containing stats about the datablobs and the "Data mempool" the local node is seeing; Example: RAM.207 50c5ce3d R.0 S.414 A.414 dup.0 | L.0 A.0 coll.0 | lag (0.0000 0.0000 0.0000) err.0 pend.0 T/F 207/207 | 0 0 0 0 0 1 0 1 3 4 5 32 62 99 0/sec ; for explanation on what each part of the string means, see the Daemon Output section |
./komodo-cli -ac_name=DORN DEX_stats
DEX_stream filename priority
This method allows a user to stream a file to the DEXP2P
Network of the Smart Chain. It is different from DEX_publish in that, DEX_stream
can help stream a file while it is increasing in size. When the command is issued, it checks the file's size and if it is more than 1 MB and the first slice hasn't been published yet, the command publishes a slice of size 1 MB using DEX_publish internally. The command must be issued each time a new slice has to be published. If the command was issued when the size was less than 1 MB or if there is no new slice to publish, then it does nothing and informs the user about the reason.
Example:
- When the command was issued, if the size was
0.86 MB
, it will returns warning. - When the command was issued, if the size was
4.42 MB
and4
slices were already published by previous issuances of the command, it returns a warning.
To continuously stream, it is recommended to repeatedly issue the command with a small sleep/wait
between each issuance.
A detailed explanation on how the command works and its usage can be found in this linked tutorial
Name | Type | Description |
---|---|---|
filename | (string) | the name of the file to be streamed; the name must be less than 15 characters long; the file must be present in the working directory from which the command to start the Komodo daemon(komodod ) was issued; not to be confused with the directory in which komodod is present |
priority | (number) | the minimum priority to be used for the broadcasted datablobs that contain the file's data; set this value above the VIP_PRIORITY level for prioritised transmission of the datablobs; for the VIP_PRIORITY being used by your node, see the value of vip in the response to the DEX_stats RPC |
Name | Type | Description |
---|---|---|
fname | (string) | the name of the file being published; here, the file referred to is the slice being published, not the actual file; the number appended after the actual file's name is a count of the number of bytes of the actual file that exist before this slice |
id | (number) | the id of the published file's locators datablob |
senderpub | (string) | the DEX_pubkey of the file's sender |
filesize | (number) | the size of the file in bytes |
fragments | (number) | the number of fragments the file has been broken down into; each fragment has a maximum size of 10000 bytes |
numlocators | (number) | the number of locators of the published file |
filehash | (string) | the SHA256 hash of the file as indicated by the publishing node |
checkhash | (string) | the SHA256 hash of the file based on all the fragments the node has currently available |
result | (string) | whether the command was successfully executed |
Name | Type | Description |
---|---|---|
result | (string) | whether the command was successfully executed |
warning | (string) | information about the error faced |
filename | (string) | the name of the file being streamed; here, the file referred to is the actual file being streamed |
filesize | (number) | the current size of the file in bytes |
offset0 | (number) | the total number bytes of the actual file that have already been published using slices |
available | (number) | the total number bytes of the actual file that are available to be published after the last publish |
needed | (number) | the total number bytes of the actual file that are needed for publishing the next slice |
./komodo-cli -ac_name=DORN DEX_stream 13-48-39.mkv 0
Response when the file size was less than 1 MB
./komodo-cli -ac_name=DORN DEX_stream 13-48-39.mkv 0
Response when the above command was issued the first time after the file size increased to more than 1 MB
./komodo-cli -ac_name=DORN DEX_stream 13-48-39.mkv 0
Response when the above command was issued the second time after the file size increased to more than 1 MB
DEX_streamsub filename priority pubkey
This method allows a user to assemble a file being streamed to the DEXP2P network using the DEX_stream command. When this command is issued for the first time, it downloads the first slice if available. On further issuance, it downloads the next slice each time and appends the downloaded slice to the file assembled till then.
To continuously build the file as more slices are available in the "data Mempool", it is recommended to repeatedly issue the command with a small sleep/wait
between each issuance.
A detailed explanation on how the command works and its usage can be found in this linked tutorial
Name | Type | Description |
---|---|---|
filename | (string) | the name of the file to be assembled; the name must be less than 15 characters long; the file must be created in the working directory from which the command to start the Komodo daemon(komodod ) was issued; not to be confused with the directory in which komodod is present |
priority | (number) | the minimum priority to be used for the broadcasted datablobs that contain the file's data; set this value above the VIP_PRIORITY level for prioritised transmission of the datablobs; for the VIP_PRIORITY being used by your node, see the value of vip in the response to the DEX_stats RPC |
pubkey | (string) | the DEX_pubkey of the node that is streaming the file |
Name | Type | Description |
---|---|---|
fname | (string) | the name of the file being downloaded; here, the file referred to is the slice being published, not the actual file; the number appended after the actual file's name is a count of the number of bytes of the actual file that exist before this slice |
id | (number) | the id of the file's locators datablob |
senderpub | (string) | the DEX_pubkey of the file's sender |
filesize | (number) | the size of the file in bytes |
fragments | (number) | the number of fragments the file has been broken down into; each fragment has a maximum size of 10000 bytes |
numlocators | (number) | the number of locators of the published file |
filehash | (string) | the SHA256 hash of the file as indicated by the publishing node |
checkhash | (string) | the SHA256 hash of the file based on all the fragments the node has currently available |
result | (string) | whether the command was successfully executed |
warning | (string) | warnings/errors if any |
./komodo-cli -ac_name=DORN DEX_streamsub 18-27-14.mkv 5
Response when the command downloaded the 6th slice
DEX_subscribe filename priority id [publisher33]
This method allows a user to construct a file from the datablobs available in its RAM. The file must have been published to the dexp2p
network using the DEX_publish method by another node.
There is a detailed explanation on how publishing and subscribing works here
Name | Type | Description |
---|---|---|
filename | (string) | the name of the file to download |
priority | (number) | the priority above the default value of the command priority with which the node should create a datablob if it needs to request missing blocks; can be 0 most of the time |
id | (string, deprecated) | DEPRECATED; use the value 0 in its place; PREVIOUSLY: id of the datablob that contains the locators information for the file the user wants to download; find the locators datablob by filtering the avaialble datablobs with tagA set to the file's name and tagB set to the word locators |
publisher33 | (string) | the DEX_pubkey of the file's publisher |
Name | Type | Description |
---|---|---|
fname | (string) | the name of the file |
id | (number) | the id of the published file's locators datablob |
senderpub | (string) | the DEX_pubkey of the file's sender |
filesize | (number) | the size of the file in bytes |
fragments | (number) | the number of fragments the file has been broken down into; each fragment has a maximum size of 10000 byte |
numlocators | (number) | the number of locators of the published file |
filehash | (string) | the SHA256 hash of the file as indicated by the publishing node |
checkhash | (string) | the SHA256 hash of the file based on all the fragments the node has currently available |
result | (string) | whether the command was successfully executed |
./komodo-cli -ac_name=DORN DEX_subscribe "roadmap2020.pdf" 0 0 01e28518858aa3515163a67deee2b19f0d30e4fa237f0aec255e4c94db0fe8d063