Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fragmentset workers #9

Merged
merged 4 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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