ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

⚡️ v0.34.0 RELEASE 🚀 #1721

Closed alanshaw closed 5 years ago

alanshaw commented 5 years ago

Ahh yeah, it got fast

🗺 What's left for release?

🔦 Highlights

🏎 Reading Protobuf DAG nodes is super fast

Reading Protobuf DAG nodes just got a serious speed boost as well as a memory reduction. Previously Protobuf DAG nodes (dag-pb nodes for short) carried a multihash property (a CIDv0) with them. This used up loads of CPU time calculating the hash for a given node as it was retrieved from storage and with the advent of CIDv1 there was no guarantee the hashing algorithm and length were correct.

So, we removed it! 🦖

Ok so that had the unfortunate consequence of making the object API a whole lot less useful when writing data - the DAG nodes you got back were basically the data you put in. Hence the object API was refactored to return CIDs instead of DAG nodes for write operations...and we all lived happily ever after.

🚤 Adding content is blazingly fast

We found a big bottleneck (or should I say small bottleneck?) that meant the bigger the file you added to IPFS, the longer it would take - oh no 😭! Good news folks, we've seen the speed of adding large files increase by 50% or more in some cases! 💥

Read all about it in the pull request notes.

🎄 HAMT support added to MFS

We're putting the whole of npm on IPFS! These days npm is like 5.3 terabytes of data and it's all going in MFS. This is super rad, but we needed a good sharding strategy because 5TB is a lorra lorra files.

If you're curious about npm on IPFS, check out the project here.

📣 IPNS over pubsub and DHT

Get informed of IPNS record updates and read and publish your IPNS records to the DHT. It's all there and it's all awesome. For those of you new to IPNS, let me give you the lowdown - IPNS puts the mutable in immutable 🤣 It's an age old problem, content addressing is rad and all that, but if I change something the hash changes - 👎 boo...but wait, IPNS solves this, you get a permenant address for changeable content - hooray \o/.

IPNS over pubsub gets the word out quicker to peers that are interested when an IPNS record changes. IPNS over DHT allows peers to find and resolve your IPNS address to some content in the first place! In the next JS IPFS release (0.35) the DHT will be enabled by default and it's going to be epic.

⚾️ CID handling improvements

Smoosh your CIDs into whatever version you like - you can now add data under a version 0 CID and get it back using a version 1 CID and vice versa. Now that you have this freedom you can encode them with whatever multibase encoding you like. Version 0 CIDs are all base58btc but if you convert to a version 1 CID you can encode it with base2, base32, base64url or whatever:

# base2
010111000000010010001000000100011011010100010010000001010010111001110001011010111100010100000111000011101010101010101101111100000001011101110001011110100001000100111010101101010111111001000111110001001010000101100010110000001000011110101110100100010101110110100010110100110000001110
# base32
bafybeicg2rebjoofv4kbyovkw7af3rpiitvnl6i7ckcywaq6xjcxnc2mby
# base58btc
QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
# base64url
uAXASIEbUSBS5xa8UHDqqt8BdxehE6tX5HxKFiwIeukV2i0wO

This is all work to smooth out the eventual transition to base32 CIDv1 by default - a move to allow CIDs to be used as valid URL origins. Have a read of this for more.

To help you craft your artisanal CIDs we've introduced a --cid-base option to a bunch of CLI commands (and ?cid-base option to a bunch of HTTP API endpoints). Check it out:

jsipfs add file.txt --cid-base=base32
added bafybeibns4lrebrxaymvyshgmki5biwh6cd53idxfpen6ysomzrywtsm44 file.txt

💪 Deps got upgrades!

We got you covered with WebUI 2.3 (quic support, responsive navbar, and a language selector), libp2p 0.24 and many other upgrades giving you a faster and smaller JS IPFS.

🏓 DHT bumped to next release

The Distributed Hash Table(tennis) is finally here! This is the biggest leap forwards for JS IPFS since sliced bread. It allows your IPFS node to find peers and content way more easily and it has full interop with Go IPFS nodes so y'all have the full IPFS network at your fingertips 💥 I know, you're welcome - send flowers to @vasco-santos.

🏗 API Changes

✅ Release Checklist

❤️ Huge thank you to everyone that made this release possible

By alphabetical order, here are all the humans that contributed to the release:

🙌🏽 Want to contribute?

Would you like to contribute to the IPFS project and don't know how? Well, there are a few places you can get started:

⁉️ Do you have questions?

The best place to ask your questions about IPFS, how it works and what you can do with it is at discuss.ipfs.io. We are also available at the #ipfs channel on Freenode.

daviddias commented 5 years ago

This release is going to be HUUUUGEEEE!!

daviddias commented 5 years ago

@alanshaw with this release, can js-ipfs move to base32 by default?

mkg20001 commented 5 years ago

@alanshaw Possibly want to make this release even bigger than it is? I'm currently working on stardust, a replacement for ws-star that actually works. I could ship it behind a flag with some help on this pr https://github.com/ipfs/js-ipfs/pull/1812 which requires this one to be finished https://github.com/libp2p/js-libp2p-crypto/pull/125

daviddias commented 5 years ago

@mkg20001 additional transports can be added through adding a custom libp2p bundle -- https://github.com/ipfs/js-ipfs#optionslibp2p. No need for special flags :)

mkg20001 commented 5 years ago

@daviddias I'm talking about replacing ws-star with stardust upstream in js-ipfs. So that EXPERIMENTAL.stardust would switch ws-star for stardust. See https://github.com/libp2p/js-libp2p-websocket-star/issues/70

alanshaw commented 5 years ago

@alanshaw with this release, can js-ipfs move to base32 by default?

I'd love it to but there's no PRs implementing it yet. Possibly in 0.35 or more likely in 0.36.

0.34 will bring js-ipfs up to speed with go-ipfs in terms of CID version agnostic get and be ahead of it with the --cid-base option.

Essentially the rough plan now is:

@alanshaw Possibly want to make this release even bigger than it is?

Absolutely not! This release needs to leave the building asap. 🤣

aphelionz commented 5 years ago

Great work everybody! Exciting stuff.

younasm commented 2 years ago

Error: /api/v0/object has been removed, use /api/v0/dag instead

I am using ipfs for image uploading it was working fine but now I am getting the above error. how should I change my code to make it work again. i am new to Ethereum please help.

uploaddoc: function(){
    const reader = new FileReader();
    reader.onloadend = function() {
      const ipfs = window.IpfsApi('ipfs.infura.io', 5001, {protocol: 'https'}) // Connect to IPFS
      console.log('ipfs-connection', ipfs);
      const buf = buffer.Buffer(reader.result) // Convert data into buffer
      ipfs.files.add(buf, (err, result) => { // Upload buffer to IPFS
        if(err) {
          console.error(err)
          swal("Error", "Something went wrong!", "error");
          return
        }
        let url = `https://ipfs.io/ipfs/${result[0].hash}`
        console.log(`Url --> ${url}`)
        $(".js-uploaded-hash").attr("data-hash", result[0].hash);
        swal("Document Uploaded!", "Thanks for choosing us!", "success");
      })
    }
    const photo = document.getElementById("memories");
    reader.readAsArrayBuffer(photo.files[0]); // Read Provided File

  },
younasm commented 2 years ago

Error: /api/v0/object has been removed, use /api/v0/dag instead

I am using ipfs for image uploading it was working fine but now I am getting the above error. how should I change my code to make it work again. i am new to Ethereum please help.

uploaddoc: function(){
    const reader = new FileReader();
    reader.onloadend = function() {
      const ipfs = window.IpfsApi('ipfs.infura.io', 5001, {protocol: 'https'}) // Connect to IPFS
      console.log('ipfs-connection', ipfs);
      const buf = buffer.Buffer(reader.result) // Convert data into buffer
      ipfs.files.add(buf, (err, result) => { // Upload buffer to IPFS
        if(err) {
          console.error(err)
          swal("Error", "Something went wrong!", "error");
          return
        }
        let url = `https://ipfs.io/ipfs/${result[0].hash}`
        console.log(`Url --> ${url}`)
        $(".js-uploaded-hash").attr("data-hash", result[0].hash);
        swal("Document Uploaded!", "Thanks for choosing us!", "success");
      })
    }
    const photo = document.getElementById("memories");
    reader.readAsArrayBuffer(photo.files[0]); // Read Provided File

  },

Hello Please anyone expert here I am waiting for help.