Our current roadmap for neume is to support decent, lens and make the crawler more generic. The below are few technical changes which I propose for this roadmap.
Save Tracks instead of NFTs
Our schema currently represents an NFT. However, multiple NFTs can represent the song (track). This leads to duplication of data. The consumer of neume has to merge NFTs into tracks.
We stuck with NFTs because it was simpler and levelDB isn't suitable for tracks.
Pros of moving to Tracks
- It will make the crawler more generic because not every protocol will publish audio as NFTs. For eg. lens.
- We will save space since multiple NFTs can point to the same track.
Problem with saving tracks in levelDB
LevelDB is a key-value database. Imagine we have the following track in our database. owners is the list of owners for this track.
{
...
"owners": [],
...
}
If two threads simultaneously update the owners field they will have to overwrite everything.
// Thread 1
const oldTrack = getTrack(id)
const newTrack = oldTrack.owners.push('0x123')
updateTrack(newTrack)
// Thread 2
const oldTrack = getTrack(id)
const newTrack = oldTrack.owners.push('0xabc')
updateTrack(newTrack)
Let's suppose thread 2 finishes last. We have the following value in our database.
{
...
"owners": ["0xabc"],
...
}
Databases like MongoDB allow to insert values into a nested field but unfortunately levelDB doesn't. We can write code and add this functionality in levelDB but it won't be flexible. If we have another field like owner in the future we will have to write more code. Not ideal.
Using sqlite to solve the above LevelDB problem
I propose to give sqlite a try. To save effort we can use ORMs such as sequalize.
We dismissed sqlite before because it was pointed out that it has slow write speed. I argue that speed isn't our top priority and how slow can sqlite be.
Make strategies more generic
To be written...
Our current roadmap for neume is to support decent, lens and make the crawler more generic. The below are few technical changes which I propose for this roadmap.
Save Tracks instead of NFTs
Our schema currently represents an NFT. However, multiple NFTs can represent the song (track). This leads to duplication of data. The consumer of neume has to merge NFTs into tracks.
We stuck with NFTs because it was simpler and levelDB isn't suitable for tracks.
Pros of moving to Tracks
Problem with saving tracks in levelDB
LevelDB is a key-value database. Imagine we have the following track in our database.
ownersis the list of owners for this track.If two threads simultaneously update the
ownersfield they will have to overwrite everything.Let's suppose thread 2 finishes last. We have the following value in our database.
Databases like MongoDB allow to insert values into a nested field but unfortunately levelDB doesn't. We can write code and add this functionality in levelDB but it won't be flexible. If we have another field like owner in the future we will have to write more code. Not ideal.
Using sqlite to solve the above LevelDB problem
I propose to give sqlite a try. To save effort we can use ORMs such as sequalize.
We dismissed sqlite before because it was pointed out that it has slow write speed. I argue that speed isn't our top priority and how slow can sqlite be.
Make strategies more generic
To be written...