mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
Add timestamp to mobymask p2p messages (#340)
* Add timestamps to mobymask logs * Fix getCurrentTime method calls --------- Co-authored-by: Dhruv Srivastava <dhruvdhs.ds@gmail.com>
This commit is contained in:
parent
c44eff36b4
commit
d221704baa
@ -83,7 +83,7 @@ export async function sendMessageToL2 (
|
||||
}
|
||||
|
||||
export function parseLibp2pMessage (log: debug.Debugger, peerId: string, data: any): void {
|
||||
log('Received a message on mobymask P2P network from peer:', peerId);
|
||||
log(`[${getCurrentTime()}] Received a message on mobymask P2P network from peer:`, peerId);
|
||||
const { kind, message } = data;
|
||||
|
||||
switch (kind) {
|
||||
@ -107,6 +107,11 @@ export function parseLibp2pMessage (log: debug.Debugger, peerId: string, data: a
|
||||
log('------------------------------------------');
|
||||
}
|
||||
|
||||
export const getCurrentTime = (): string => {
|
||||
const now = new Date();
|
||||
return `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
|
||||
};
|
||||
|
||||
function _parseInvocation (log: debug.Debugger, msg: any): void {
|
||||
log('Signed invocations:');
|
||||
log(JSON.stringify(msg, null, 2));
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/49721#issuecomment-1319854183
|
||||
} from '@cerc-io/peer';
|
||||
|
||||
import { sendMessageToL2 } from './libp2p-utils';
|
||||
import { getCurrentTime, sendMessageToL2 } from './libp2p-utils';
|
||||
import { readPeerId } from '@cerc-io/cli';
|
||||
import { ethers } from 'ethers';
|
||||
|
||||
@ -57,7 +57,7 @@ export const main = async (): Promise<any> => {
|
||||
const wallet = new ethers.Wallet(argv.privateKey, ethProvider);
|
||||
|
||||
peer.subscribeTopic(peerConfig.pubSubTopic, (peerId, data) => {
|
||||
log('Received a message on mobymask P2P network from peer:', peerId);
|
||||
log(`[${getCurrentTime()}] Received a message on mobymask P2P network from peer:`, peerId);
|
||||
|
||||
// TODO: throttle message handler
|
||||
sendMessageToL2(wallet, argv, data);
|
||||
|
Loading…
Reference in New Issue
Block a user