1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

debug tweaks

This commit is contained in:
Matthias Kretschmann 2020-09-25 14:21:22 +02:00
parent ca19be4390
commit 6e1a2b9abf
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 19 additions and 3 deletions

5
package-lock.json generated
View File

@ -6637,6 +6637,11 @@
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
"dev": true
},
"lzma": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/lzma/-/lzma-2.3.2.tgz",
"integrity": "sha1-N4OySFi5wOdHoN88vx+1/KqSxEE="
},
"macos-release": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.4.1.tgz",

View File

@ -45,6 +45,7 @@
"@oceanprotocol/contracts": "^0.4.4",
"decimal.js": "^10.2.0",
"fs": "0.0.1-security",
"lzma": "^2.3.2",
"node-fetch": "^2.6.1",
"save-file": "^2.3.1",
"uuid": "^8.3.0",

View File

@ -6,6 +6,7 @@ import Web3 from 'web3'
import defaultDDOContractABI from '@oceanprotocol/contracts/artifacts/Metadata.json'
import { didZeroX } from '../utils'
import { Compressor } from 'xz'
import { LZMA } from 'lzma'
/**
* Provides an interface with Metadata Store.
@ -37,12 +38,21 @@ export class OnChainMetadataStore {
/**
* Compress DDO using xz/lzma2
*/
public async compressDDO(ddo: DDO): Promise<string> {
const data = DDO.serialize(ddo)
const buffer = Buffer.from(data)
const buffer = Buffer.from(data, 'utf-8')
const compression = new Compressor({ preset: 9 })
const compressed = await compression.updatePromise(buffer)
return this.getHex(compressed.toString())
await compression.updatePromise(buffer)
const compressed = await compression.finalPromise()
// const lzma = new LZMA()
// lzma.disableEndMark = true
// const compressedLzma = lzma.compress(data, 9)
const compressedXz = compressed.toJSON().data
console.log(compressedXz)
// console.log(compressedLzma)
const final = this.getHex(compressedXz)
return final
}
/**