-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Inkvi
committed
Mar 21, 2024
1 parent
7e541c4
commit 124d09d
Showing
4 changed files
with
142 additions
and
30 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
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,25 @@ | ||
import { DatabaseModel } from "@ponder/core/src/types/model"; | ||
import { Infer } from "@ponder/core/src/schema/types"; | ||
import { schema } from "@/generated"; | ||
|
||
export enum StatName { | ||
SendPackets = 'SendPackets', | ||
RecvPackets = 'RecvPackets', | ||
AckPackets = 'AckPackets', | ||
WriteAckPacket = 'WriteAckPacket', | ||
} | ||
|
||
export async function updateStats<T extends DatabaseModel<Infer<schema>["Stats"]>>(Stats: T, id: StatName) { | ||
await Stats.upsert({ | ||
id: id, | ||
create: { | ||
val: 1, | ||
}, | ||
update: ({current}: T) => { | ||
return { | ||
val: current.val + 1 | ||
} | ||
} | ||
}); | ||
|
||
} |