-
Notifications
You must be signed in to change notification settings - Fork 188
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(torii-indexer): task manager & parallelize erc transfers #2913
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ mod constants; | |
#[path = "test.rs"] | ||
mod test; | ||
|
||
mod task_manager; | ||
pub mod engine; | ||
pub mod processors; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,15 @@ where | |
true | ||
} | ||
|
||
fn task_priority(&self) -> usize { | ||
1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't an enum more idiomatic, or you need logic around this priority, or a priority value seems more manageable? |
||
} | ||
|
||
fn task_identifier(&self, _event: &Event) -> u64 { | ||
// TODO. for now event messages are not parallelized | ||
0 | ||
} | ||
|
||
async fn process( | ||
&self, | ||
_world: &WorldContractReader<P>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,15 @@ where | |
true | ||
} | ||
|
||
fn task_priority(&self) -> usize { | ||
1 | ||
} | ||
|
||
fn task_identifier(&self, _event: &Event) -> u64 { | ||
// TODO. for now metadata updates are not parallelized | ||
0 | ||
} | ||
Comment on lines
+37
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Ohayo! Consider implementing proper task identification, sensei. The current implementation returns a hardcoded Consider implementing a proper task identification strategy based on:
fn task_identifier(&self, _event: &Event) -> u64 {
- // TODO. for now metadata updates are not parallelized
- 0
+ let mut hasher = DefaultHasher::new();
+ event.resource.hash(&mut hasher);
+ hasher.finish()
}
|
||
|
||
async fn process( | ||
&self, | ||
_world: &WorldContractReader<P>, | ||
|
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.
Initialize
task_manager
field inEngine
Ohayo, sensei! On line 211, the
Engine
struct has a new fieldtask_manager
but it's not initialized in the constructor. Make sure to initializetask_manager
in theEngine::new
method to prevent a runtime error.Apply this diff to initialize
task_manager
: