mafintosh / torrent-stream

The low level streaming torrent engine that peerflix uses
MIT License
1.94k stars 228 forks source link

Move blocklist IPv4 parsing logic out of torrent-stream #65

Closed asapach closed 10 years ago

asapach commented 10 years ago

As discussed in #63, we should move computationally intensive IPv4 parsing out of the inner loop in lib/blocklist.js, preferably altogether into peerflix.

BastienClement commented 10 years ago

Right now I don't think we should drop ip dependency from torrent-stream. And certainly not move it to peerflix (meaning changing the engine.block() API to receive number, seems odd). IPv4 string representations are used all around torrent-stream. Using integer representation is only related to blocklist interval checking.

I think IPv4 parsing should rather be restricted inside blocklist.js along with a nice API to the blocklist component. Making something we can ultimately move out of torrent-stream in its own ip-blocklist module.

var list = blocklist(inital)

list.add(ip)
list.add(first, last)

// This one could be omitted since append-only list is acceptable for this
// If implementation of removal is harder than insertion
list.remove(ip)
list.remove(first, last)

list.contains(ip)

But yes, parsing IPs every lookup is stupid and could be fixed right now. But this is related to blocklist internal optimization.

BastienClement commented 10 years ago

I think #67 pretty much settle this issue. The blocklist module can now be pulled out of torrent-stream along with the ip dependency.