Skip to content

Commit

Permalink
Merge pull request #9 from GeorgeTsagk/add-fragmentset-workers
Browse files Browse the repository at this point in the history
Add fragmentset workers
  • Loading branch information
GeorgeTsagk committed Jun 11, 2022
2 parents dfe9c34 + 689a663 commit 8f49476
Show file tree
Hide file tree
Showing 5 changed files with 384 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project mainly serves as a demonstration to the `DataSig` and `DataStruct`

# Usage

The receiving node must have `--accept-keysend` enabled in order to accept the spontaneous payments carrying data.

Rename `config.sample.yaml` to `config.yaml` and fill in the URL, macaroon path and TLS path for your LND.

Configure the `tlv_key` for `data_sig` and `data_struct`, this needs to be a `uint64` number that is **odd** and **greater than 65536**.
Expand Down
1 change: 1 addition & 0 deletions config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ data_struct:
max_data_size: 5242880 # Maximum allowed size for data to be transmitted.
tlv_key: 293345191 # replace with desired TLV key to insert DataStruct structure into
fragment_size: 1024 # replace with desired maximum size per fragment
fragment_workers: 10 #replace with desired number of workers to handle RPC calls towards LND
317 changes: 316 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions src/handle-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ const {
sendDataToAddress,
setDestinationAddress,
getDestinationAddress,
sendFragmentsSync } = require('./write-sats')
sendFragmentsSync,
sendFragmentsAsync } = require('./write-sats')
const { encodeDataStruct, dataToDataStructArray } = require('./utils/data-struct/data-struct')
const { encodeAppFileMessage, encodeAppTextMessage } = require('./app-protocol/app-protocol')
const config = require('./config/config-loader')

const conf = config.getConfig()

let handlers = {}

Expand Down Expand Up @@ -36,7 +40,15 @@ handlers['send'] = async (args) => {
const appMessageBuf = await encodeAppFileMessage(filename, buff)
const dataStructs = dataToDataStructArray(appMessageBuf)

sendFragmentsSync(dataStructs, 0, 0)
if (conf.data_struct.fragment_workers <= 0) {
sendFragmentsSync(dataStructs, 0, 0)
} else {
sendFragmentsAsync(
dataStructs,
conf.data_struct.fragment_workers
)
}

} catch (e) {
console.log(e)
}
Expand Down

0 comments on commit 8f49476

Please sign in to comment.