I want to check provided string is a valid IPFS or IPNS path or not under ipfs domain.
For example when I do:
ipfs ls <invalid-hash>
//waits keep searching ...
This will not return anything but halts within the program, so I would need to wait not knowing given hash is valid or not.
I could wait N-seconds as a threshold for ipfs to return results for ipfs cat valid-hash, ipfs ls valid-hash but results of ipfs cat valid-hash or ipfs ls valid-hash may take longer than N-seconds, which is not trustable to rely on.
[~]$ ipfs cat <hash-id that exists in the ipfs domain>
//returns a results maybe after 10 minutes if the hash-id string is valid.
[~]$ ipfs cat <hash-id that does not exists in the ipfs domain>
//HALTS. and does not return me that hash-id is invalid.
I have used: https://github.com/xicombd/is-ipfs but an invalid-hash string that I am giving into functions returns true, so it does not work properly on my side, any advice?
For example: (I am running commands inside node app.)
[$] node
const isIPFS = require('is-ipfs')
> isIPFS.multihash('QmYooooooooooooooooooooooooooooooooaoooooooooo')
true //returns true but it is an invalid ipfs hash that does not exist in the ipfs domain and should have returned false.
Thank you for your valuable time and help.
ipfs add -r somefile.txtthis would returnadded <hash_id> somefile.txt. And later I can do this:ipfs cat <hash_id>. But if I give some random hash_id that is not exist in the ipfs domain:ipfs cat <some_hash_id>will enter into while() and halts. This will not return me that thatipfs hash_idexists in the ipfs domain. So there is no way I can know that is the entered hash_id points to a allocated memory. – alper Nov 30 '16 at 10:53ipfs cat <hash_id>oripfs ls <hash_id>; I want to know that; does<hash_id> stringis valid and exist in the ipfs domain so it will be okay for me to waitipfs {cat | ls}’s response even it takes a long time. – alper Nov 30 '16 at 10:54