# All files / server bitswap.js

15.79% Statements 3/19
0% Branches 0/14
0% Functions 0/2
15.79% Lines 3/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    411x
    1x
    1x

     import { expose } from 'postmsg-rpc'
    import { post } from 'prepost'
    import { isBig, bigToJson } from '../serialization/big'

    export default function (getIpfs, opts) {
      return {
        stat: expose('ipfs.bitswap.stat', post(
          (...args) => getIpfs().bitswap.stat(...args),
          (stats) => {
            if (stats) {
              if (isBig(stats.blocksReceived)) {
                stats.blocksReceived = bigToJson(stats.blocksReceived)
              }

              if (isBig(stats.dataReceived)) {
                stats.dataReceived = bigToJson(stats.dataReceived)
              }

              if (isBig(stats.blocksSent)) {
                stats.blocksSent = bigToJson(stats.blocksSent)
              }

              if (isBig(stats.dataSent)) {
                stats.dataSent = bigToJson(stats.dataSent)
              }

              if (isBig(stats.dupBlksReceived)) {
                stats.dupBlksReceived = bigToJson(stats.dupBlksReceived)
              }

              if (isBig(stats.dupDataReceived)) {
                stats.dupDataReceived = bigToJson(stats.dupDataReceived)
              }
            }

            return stats
          }
        ), opts)
      }
    }