-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: leveldb #44
feat: leveldb #44
Conversation
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
throw new Error( | ||
"Error: Instantiation failed: Use DBService.getInstance() instead of new." | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making it a singleton?
If the instance already exists just return it rather than throwing
@@ -11,8 +10,18 @@ export interface RunOptions extends WatchtowerOptions { | |||
rpc: string[]; | |||
deploymentBlock: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was the deploymentBlock an array?
is this how you plan to run it in multiple networks? If so, in principle, it feels a better idea to use separated instances
|
||
export type DBLevel = Level<string, string>; | ||
|
||
export default class DBService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This name is a bit generic (but it depeds on Level db).
It would be great if you can use the Repository or DAO pattern to abstract the persistance. This way, this implementation will use Level DB, but others could use anything else.
This could have a repository or DAO layer, and then you create a ContextRepository
interface, with a ContextRepositoryLevel
or ContextRepositoryImpl
(since we don't have more)
} | ||
|
||
public getDB() { | ||
return this.db; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the repository pattern, you would not expose this, but would provide for the service layer the basic CRUD operations you need
} | ||
|
||
export type SingularRunOptions = Omit<RunOptions, "rpc" | "deploymentBlock"> & { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have "plural" TBH, this should be the default run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR!
Adding some comments, no need to address for this PR, but it would be great to consider for the top of the waterfall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Given that we are already using a NoSQL database and we need some storage, I dropped in
leveldb
as the NoSQL solution. This allows us to eliminate all external dependencies, making it friendlier for spinning up in bandwidth constrained environments (ie. hackathons), and reduces complexity with deployment (no requirement for external SQL servers).Changes
level
packages and `ts.db
singleton for holding the database.commander
.await
that were dependent onsecret
lookups previously.How to test
No testing for this PR, besides
eslint
andprettier
passing, excluding to-be-deprecated actions. This PR is mostly for "readability".Related Issues
Closes #40