-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### TL;DR Refactored RPC to wrap the needed rpc calls and return already serialized data. This way we don't have to repeat the request creation and response handling whenever we need it. We have fixed queries so maintaining wrappers doesn't seem like a problem ### What changed? - Moved RPC-related functionality from `common` package to a new `rpc` package - Created a new `Client` struct in the `rpc` package to handle RPC operations - Refactored worker logic to use the new RPC client - Updated orchestrator components to use the new RPC client - Added utility functions for handling big.Int slices and RPC configurations ### How to test? 1. Run the indexer with the updated code 2. Verify that block fetching, log retrieval, and trace processing work as expected 3. Check that batch processing is functioning correctly by monitoring RPC calls 4. Ensure that the orchestrator components (poller, committer, failure recoverer) are operating properly with the new RPC client ### Why make this change? This refactoring improves the overall structure and performance of the indexer: 1. Better separation of concerns by moving RPC-related code to its own package 2. Improved maintainability and readability of the codebase 3. Easier extension and modification of RPC-related functionality in the future
- Loading branch information
Showing
17 changed files
with
405 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ type BlockData struct { | |
Logs []Log | ||
Traces []Trace | ||
} | ||
|
||
type RawBlock = map[string]interface{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package common | ||
|
||
import "math/big" | ||
|
||
func BigIntSliceToChunks(values []*big.Int, chunkSize int) [][]*big.Int { | ||
if chunkSize >= len(values) || chunkSize <= 0 { | ||
return [][]*big.Int{values} | ||
} | ||
var chunks [][]*big.Int | ||
for i := 0; i < len(values); i += chunkSize { | ||
end := i + chunkSize | ||
if end > len(values) { | ||
end = len(values) | ||
} | ||
chunks = append(chunks, values[i:end]) | ||
} | ||
return chunks | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.