Skip to content

Commit

Permalink
sync: buildEvents and decodeEvents modfied
Browse files Browse the repository at this point in the history
  • Loading branch information
khaidarkairbek authored and kyscott18 committed Nov 10, 2024
1 parent a7052f3 commit e7dcfbb
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 117 deletions.
23 changes: 15 additions & 8 deletions packages/core/src/sync-realtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export type RealtimeSync = {
start(args: {
syncProgress: Pick<SyncProgress, "finalized">;
initialChildAddresses: Map<Factory, Set<Address>>;
}): Promise<Queue<void, BlockWithEventData>>;
}): Promise<
Queue<void, Omit<BlockWithEventData, "traces"> & { traces: SyncTrace[] }>
>;
kill(): Promise<void>;
unfinalizedBlocks: LightBlock[];
finalizedChildAddresses: Map<Factory, Set<Address>>;
Expand All @@ -67,17 +69,15 @@ export type BlockWithEventData = {
filters: Set<Filter>;
logs: SyncLog[];
factoryLogs: SyncLog[];
traces: SyncTrace[];
traces: SyncTraceFlat[];
transactions: SyncTransaction[];
transactionReceipts: SyncTransactionReceipt[];
};

export type RealtimeSyncEvent =
| ({
type: "block";
} & Omit<BlockWithEventData, "traces"> & {
traces: SyncTraceFlat[];
})
} & BlockWithEventData)
| {
type: "finalize";
block: LightBlock;
Expand Down Expand Up @@ -111,7 +111,10 @@ export const createRealtimeSync = (
* `parentHash` => `hash`.
*/
let unfinalizedBlocks: LightBlock[] = [];
let queue: Queue<void, Omit<BlockWithEventData, "filters">>;
let queue: Queue<
void,
Omit<BlockWithEventData, "filters" | "traces"> & { traces: SyncTrace[] }
>;
let consecutiveErrors = 0;
let interval: NodeJS.Timeout | undefined;

Expand Down Expand Up @@ -177,7 +180,9 @@ export const createRealtimeSync = (
traces,
transactions,
transactionReceipts,
}: Omit<BlockWithEventData, "filters">) => {
}: Omit<BlockWithEventData, "filters" | "traces"> & {
traces: SyncTrace[];
}) => {
args.common.logger.debug({
service: "realtime",
msg: `Started syncing '${args.network.name}' block ${hexToNumber(block.number)}`,
Expand Down Expand Up @@ -608,7 +613,9 @@ export const createRealtimeSync = (
*/
const fetchBlockEventData = async (
block: SyncBlock,
): Promise<Omit<BlockWithEventData, "filters">> => {
): Promise<
Omit<BlockWithEventData, "filters" | "traces"> & { traces: SyncTrace[] }
> => {
////////
// Logs
////////
Expand Down
Loading

0 comments on commit e7dcfbb

Please sign in to comment.