ECLib

ECLib

new ECLib(optsopt)

This represents our interface with the erasure coding layer.
Parameters:
Name Type Attributes Description
opts Object <optional>
Contains options used by the library
Properties
Name Type Attributes Default Description
bc_id Number <optional>
0 Backend ID
k Number <optional>
8 Number of data fragments
m Number <optional>
4 Number of parity fragments
w Number <optional>
0 word size (in bits)
hd Number <optional>
0 hamming distance (==m for Reed-Solomon)
ct Number <optional>
0 checksum type
Source:

Methods

decode(fragmentArray, metadataCheck, callback)

This decodes the fragments array.
Parameters:
Name Type Description
fragmentArray Array.<Buffer> The fragment array to decode
metadataCheck Boolean Checking of the metadata
callback function (err, decodedData)
Source:

destroy(callbackopt) → {Number}

This destroys the current instance.
Parameters:
Name Type Attributes Description
callback function <optional>
callback(eclib, resultCode, err)
Source:
Returns:
- Result code
Type
Number

encode(data, callback)

This encodes the data.
Parameters:
Name Type Description
data Buffer The data to be encoded
callback function callback(status, encodedDataArray, encodedParityArray, encodedFragmentLen)
Source:

encodev(bufArray, callback)

This encodes the data array.
Parameters:
Name Type Description
bufArray Array.<Buffer> Buffers to be encoded
callback function callback(status, encodedDataArray, encodedParityArray, encodedFragmentLen)
Source:

init(callbackopt) → {Number}

This creates a new instance, using the options set at construction
Parameters:
Name Type Attributes Description
callback function <optional>
callback(eclib, instanceId, error)
Source:
Returns:
- Instance id
Type
Number

reconstruct(availFragments, fragmentIds, callback)

Reconstruct missing fragments.
Parameters:
Name Type Description
availFragments Array.<Buffer> Fragments available for reconstruction
fragmentIds Number Missing fragment ids
callback function (err, allFragments)
Source:

reconstructFragment(availFragments, fragmentId, callback)

Reconstruct a missing fragment.
Parameters:
Name Type Description
availFragments Array.<Buffer> Fragments available for reconstruction
fragmentId Number Missing fragment id
callback function (err, reconstructedFragment)
Source: