textileio / js-powergate-client

Typescript/Javascript client for Textile's Powergate
https://docs.textile.io/powergate
MIT License
45 stars 16 forks source link

pow.ffs.setDefaultStorageConfig(customConfig) #132

Closed howlwindy closed 4 years ago

howlwindy commented 4 years ago

my step below

const customConfig = { "hot": { "enabled": true, "allowUnfreeze": false, "unfreezeMaxPrice": 0, "ipfs": { "addTimeout": 30 }, }, "cold": { "enabled": true, "filecoin": { "repFactor": 5, "dealMinDuration": 1036800, "excludedMiners": null, "trustedMiners": [ "t016304", "t016304", "t016305", "t016306", "t016309" ], "countryCodes": null, "renew": { "enabled": false, "threshold": 0 }, "addr": "t3xao2uyz37six5dkyeuaq7n5krgzoo5tc3khtqmfjcelxt36mjfdkuwnm7tnpjgh6fysujekrpg4qnw5tn3cq", "maxPrice": 0, "fastRetrieval": false } }, "repairable": false } const pow = createPow({ host }) const { token } = await pow.ffs.create() pow.setToken(token) pow.ffs.setDefaultStorageConfig(customConfig)

source code -> util.js -> line32 -> hot.setEnabled(obj.enabled)

error below Error: default cid config is invalid: hot-ipfs config is invalid: invalid ipfs config: add timeout should be greater than 0 seconds, got 0 Error: default cid config is invalid: hot-ipfs config is invalid: invalid ipfs config: add timeout should be greater than 0 seconds, got 0

i wanna know the addTimeout is 30, but why error catch?

asutula commented 4 years ago

Thanks for reporting. Will take a closer look and report back here.

asutula commented 4 years ago

@kingHawkWin can you tell me what version of @textile/powergate-client you are using and what Powergate host you are connecting to? Thanks.

asutula commented 4 years ago

Also, just looking at the property names on your customConfig object... some of the names are not correct. How are you determining how that config object should be shaped and what the property names are? If you're not using Typescript, your best bet is to call await pow.ffs.defaultStorageConfig(), and inspect the returned object's defaultStorageConfig property to see exactly what the StorageConfig object looks like. You can event just modify it then pass it into await pow.ffs.setDefaultStorageConfig(customConfig).

asutula commented 4 years ago

Ok, I have a good final answer for you. The problem specifically with the addTimeout is because the Powergate server you're connected to has been updated and the @textile/powergate-client hasn't been updated to account for a breaking gRPC change. That change can be seen here where the IpfsConfig index was changed. This is a bug and @textile/powergate-client needs to be updated to fix it. I'll do that now and report back here when the release is out.

But also, the things I mentioned in the previous comment will be problems for you as well. Be sure to address those things as well.

asutula commented 4 years ago

Ok 2.0.0 is released. Please update.

OneilYang commented 4 years ago

Great~ Thanks for your fast supports! I'm his friend and will tell him what he should to check, :)

howlwindy commented 4 years ago

Hi asutula, Thanks for your helps to sovled this issue and this really helpful to me. I totally follow your instrution to call await pow.ffs.defaultStorageConfig() and get the default config with correct names. But the banlance of default addr is 0, it cannot uplaod anything , so I update with my addr with some banlance values, it may work to pay for miner, and then the new error happens as below: please see https://github.com/textileio/js-powergate-client/issues/135