Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neume version 2.1 #10

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

neume version 2.1 #10

wants to merge 15 commits into from

Conversation

il3ven
Copy link
Collaborator

@il3ven il3ven commented Jun 1, 2023

Check the individual commits for detailed description.

il3ven added 8 commits June 1, 2023 00:32
LocalStorage is similar to the local-storage present in browsers.

It is a simple key-value database powered by LevelDB.

Each strategy can have its own localstorage and use it to store any data
other than tracks.

Strategies are free to use it however they wish.

The purpose of localstorage is to store intermediate data. Here tracks
are the final data.

For example, a strategy like SoundProtocol needs to keep track of
contracts which can mint NFTs and listen for updates on them.
LocalStorage can be used here.

Earlier, we created a JSON file to store the data required by
SoundProtocol. LocalStorage replaces that JSON file as it is more
generic and scalable.
Major changes:

- The Strategy class has been changed. All strategies implement this
class.
- Introduce a concept of *components*.
- Add Lens strategy.
- Refactor Sound Protocol strategy according to the new strucutre.
- Introduce multi-chain strategies.
- Changes in daemon.ts, neume.ts to run the new refactored strategies.

What are components?

Each strategy is a class and it can define functions. What if we want
to share some functions among strategies. The answer to do that is
components.

For example, `ethGetLogs` is a component that can be used to fetch
logs.

Difference between components and utils:

Utils are simple functions which can be called from anywhere.
Components can only be called from inside strategies. We use the `this`
keyword to enforce it. TypeScript helps here by defining the type of
`this`.

Why can't we have utils instead of components?

Components are aware that they will be called from a strategy.
Therefore, they can use the `this` keyword to fetch information about
the strategy and act upon it.

For example, the `ethGetLogs` component can use
`this.chain` to get the chain of the strategy and fetch logs from the
appropriate chain.

If `ethGetLogs` was a simple function we would have to pass the chain
as an argument. It is okay if it is just chain but functions often
need more information than just chain. Passing 10 parameters is not
ideal and problematic from a refactor point of view.

About `handleTransfer` component:

It is a component that can be used by any strategy to listen for
ERC721 transfer events. The component is heavily opnionated.
- use WAL mode for sqlite
Under heavy load, I was facing knex timeout errors. WAL mode fixes it.

- update test cases

- more utility functions for the database and bug fixes
- update remaining strategies according to the new Strategy interface

- catch a plethora of bugs; introduce many checks to catch incorrect
tracks

- block numbers are now saved per strategy
- Remove crawl and filter-contracts command. The daemon command now
handles both functionalities.

- Update init command.

- Daemon now runs each strategy individually.

Earlier, if a strategy A was at block number X then strategy B was at
X too. Now, all strategies run independently. Very obvious but
significant change.

- Update sync command according to the new database.

- Update JSON RPC endpoints for syncing.
do not create files if they already exists.
il3ven added 7 commits August 2, 2023 16:02
- Instead of using `upsertTrack` to update token, introduced `upsertToken`
function. `upsertTrack` used more bandwidth and required calling `getTrack`
before.

- Instead of using multiple insert, use one insert for multiple writes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant