Skip to content

Commit

Permalink
Merge pull request #5 from ChainSafeSystems/master
Browse files Browse the repository at this point in the history
Added a time cache and a topic mapping.
  • Loading branch information
vasco-santos committed Feb 8, 2019
2 parents 96f5334 + b1e0695 commit 9a395b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -60,7 +60,8 @@
"err-code": "^1.1.2",
"length-prefixed-stream": "^1.6.0",
"protons": "^1.0.1",
"pull-pushable": "^2.2.0"
"pull-pushable": "^2.2.0",
"time-cache": "~0.3.0"
},
"contributors": [
"Vasco Santos <vasco.santos@moxy.studio>"
Expand Down
16 changes: 15 additions & 1 deletion src/index.js
Expand Up @@ -4,7 +4,7 @@ const EventEmitter = require('events')
const pull = require('pull-stream/pull')
const empty = require('pull-stream/sources/empty')
const asyncEach = require('async/each')

const TimeCache = require('time-cache')
const debug = require('debug')
const errcode = require('err-code')

Expand Down Expand Up @@ -32,6 +32,20 @@ class PubsubBaseProtocol extends EventEmitter {
this.libp2p = libp2p
this.started = false

/**
* Map of topics to which peers are subscribed to
*
* @type {Map<string, Peer>}
*/
this.topics = new Map()

/**
* Cache of seen messages
*
* @type {TimeCache}
*/
this.seenCache = new TimeCache()

/**
* Map of peers.
*
Expand Down

0 comments on commit 9a395b2

Please sign in to comment.