From 2df4baac3e8ea07df0311415552d0dff26963dc4 Mon Sep 17 00:00:00 2001 From: Bruce Date: Mon, 11 Oct 2021 16:46:22 +0800 Subject: [PATCH] remove some log --- packages/wsrpc/src/global.ts | 2 -- packages/wsrpc/src/matcher/index.ts | 5 +---- packages/wsrpc/src/puber/dispatch.ts | 1 + packages/wsrpc/src/suber/index.ts | 22 +++++++--------------- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/packages/wsrpc/src/global.ts b/packages/wsrpc/src/global.ts index 3bc893d..6c595d5 100644 --- a/packages/wsrpc/src/global.ts +++ b/packages/wsrpc/src/global.ts @@ -88,12 +88,10 @@ class G { chain = chain ConnCntMap[chain] = ConnCntMap[chain] || {} ConnCntMap[chain][pid] = ConnCntMap[chain][pid] || 0 - log.debug(`increase ${chain} pid[${pid}] connection count: ${ConnCntMap[chain][pid]}`) ConnCntMap[chain][pid] += 1 } static decrConnCnt(chain: string, pid: IDT) { - log.debug(`decrease ${chain} pid[${pid}] connection count: ${ConnCntMap[chain][pid]}`) ConnCntMap[chain][pid] -= 1 if (ConnCntMap[chain][pid] < 1) { delete ConnCntMap[chain][pid] diff --git a/packages/wsrpc/src/matcher/index.ts b/packages/wsrpc/src/matcher/index.ts index f093f85..b2e26c6 100644 --- a/packages/wsrpc/src/matcher/index.ts +++ b/packages/wsrpc/src/matcher/index.ts @@ -195,7 +195,6 @@ class Matcher { const kvStatOk = GG.getServerStatus(chain, NodeType.Kv) const memOpen = GG.getSuberEnable(chain, NodeType.Mem) const memStatOk = GG.getServerStatus(chain, NodeType.Mem) - log.debug(`puber before bind: kv[%o] mem[%o]`, puber.kvSubId, puber.memSubId) if (kvOpen && kvStatOk) { re = await suberBind(chain, puber, NodeType.Kv) @@ -203,7 +202,6 @@ class Matcher { log.error(`${chain}-${pid} bind node suber error: %o`, re.value) return Err(`${chain}-${pid} bind node suber error`) } - log.debug(`puber after bind kv: kv[%o] mem[%o]`, puber.kvSubId, puber.memSubId) } if (memOpen && memStatOk) { @@ -229,7 +227,6 @@ class Matcher { let type = ReqTyp.Rpc let subsId if (isUnsubReq(method)) { - log.debug(`${chain} pid[${pid}] pre handle unsubscribe request: ${method}: %o`, data.params) if (data.params!.length < 1 || !Suber.isSubscribeID(data.params![0])) { return Err(`invalid unsubscribe params: ${data.params![0]}`) } @@ -258,7 +255,7 @@ class Matcher { } as ReqT Puber.addReq(id, req.id) Matcher.addReqCache(req) - log.info(`new ${chain} ${pid} ${subType} request cache: ${JSON.stringify(req)}`) + log.info(`new ${chain} ${pid} ${subType} request method[${method}] originId[${data.id}] cache id [${req.id}]`) data.id = req.id as string return Ok(data) diff --git a/packages/wsrpc/src/puber/dispatch.ts b/packages/wsrpc/src/puber/dispatch.ts index 906f474..295b7ee 100644 --- a/packages/wsrpc/src/puber/dispatch.ts +++ b/packages/wsrpc/src/puber/dispatch.ts @@ -106,6 +106,7 @@ export async function dispatchWs(chain: string, data: ReqDataT, puber: Puber, st if (Cacher.statusOk(chain)) {// no need to clear puber.subid and suber.pubers const res = { id, jsonrpc } as WsData let tmethod = method + // cache for block hash at 0 block number if (method === 'chain_getBlockHash' && (params?.length === 1 && params[0] === 0)) { // log.debug(`${chain}-${nodeId} get ws initial block hash`) tmethod = `${method}_0` diff --git a/packages/wsrpc/src/suber/index.ts b/packages/wsrpc/src/suber/index.ts index bc0f4fb..6ea0308 100644 --- a/packages/wsrpc/src/suber/index.ts +++ b/packages/wsrpc/src/suber/index.ts @@ -95,8 +95,6 @@ async function parseReq(dat: WsData, chain: string): PResultT { function handleUnsubscribe(req: ReqT, dres: boolean): void { // rem subed topic, update puber.topics del submap // emit done event when puber.topics.size == 0 - log.info(`handle ${req.chain} pid[${req.pid}] unsubscribe response subscript id[${req.subsId}] params: %o`, req.params) - const pubId = req.pubId const re = Puber.get(pubId) let puber @@ -122,7 +120,6 @@ function handleUnsubscribe(req: ReqT, dres: boolean): void { GG.remSubTopic(req.chain, req.pid, subsId) GG.delSubReqMap(subsId) - log.info(`clear ${req.chain} pid[${req.pid}] subscribe context cache: subsId[${subsId}] reqId[${reqId}]`) if (puber !== undefined) { puber.topics.delete(subsId) @@ -190,14 +187,13 @@ async function dataParse(data: WebSocket.Data, chain: string, subType: NodeType, dat = JSON.parse(dat.result) } // dat.error: no need handle - // log.debug(`${chain} new kv ws response method[${dat.method}] ID[${dat.id || dat.subscription}]: ${dat.error}`) - } else if (subType === NodeType.Mem) { - // log.debug(`${chain} new memory node ws response method[${dat.method}] ID[${dat.id || dat.subscription}]: ${dat.error}`) - } else { - // log.debug(`${chain} new node ws response method[${dat.method}] ID[${dat.id || dat.subscription}]: ${dat.error}`) - } - // NOTE: if asynclize parseReqId, - // subReqMap may uninit, then miss the first data response + } + // else if (subType === NodeType.Mem) { + // // log.debug(`${chain} new memory node ws response method[${dat.method}] ID[${dat.id || dat.subscription}]: ${dat.error}`) + // } else { + // // log.debug(`${chain} new node ws response method[${dat.method}] ID[${dat.id || dat.subscription}]: ${dat.error}`) + // } + let re: any = await parseReq(dat, chain) if (isErr(re)) { log.error(`parse ${chain} request cache error: %o`, re.value) @@ -232,7 +228,6 @@ async function dataParse(data: WebSocket.Data, chain: string, subType: NodeType, Matcher.updateReqCache(req) Matcher.delReqCacheByPubStat(req.id) Puber.remReq(req.pubId, req.id) - log.info(`delete ${req.chain} pid[${req.pid}] non-subscribe cache request ID[${req.id}]: %o`, req.method) } else { updateStatistic(req, data.toString()) } @@ -276,16 +271,13 @@ async function dataParse(data: WebSocket.Data, chain: string, subType: NodeType, const cache = await Dao.fetchSubscribeResponse(subsId) if (isSome(cache)) { - log.warn(`${req.chain} pid[${req.pid}] puber[${req.pubId}] has response not sent yet, send now [${subsId}].`) puberSend(req, cache.value) // set expire duration to 1 minute, since high concurrency will // block the subscribe response, once receive response, clear Dao.clearSubscribeResponse(subsId) } - log.info(`${req.chain} pid[${req.pid}] puber[${req.pubId}] subscribe topic[${req.method}] params[${req.params}] successfully: ${subsId}`) } else { // rpc request - log.info(`New web socket response ${req.chain} pid[${req.pid}] puber[${req.pubId}] method[${req.method}] params[${req.params}]`) dataToSend = JSON.stringify(dat) // } return Ok({ req, data: dataToSend })