Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyperdrive

Package Overview
Dependencies
Maintainers
1
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperdrive - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

2

lib/feed-state.js

@@ -170,2 +170,3 @@ var events = require('events')

self.want.splice(remove[j], 1)
self.emit('unwant', want.block)
want.callback(null, null)

@@ -210,2 +211,3 @@ }

self.want.splice(remove[j], 1)
self.emit('unwant', want.block)
want.callback(null, data)

@@ -212,0 +214,0 @@ }

@@ -10,2 +10,3 @@ var protocol = require('./protocol')

this.name = opts.name || 'unknown'
this.prioritized = 0
this.drive = drive

@@ -31,2 +32,12 @@ this.peers = []

subswarm.feed.on('want', function () {
self.prioritized++
subswarm.fetch()
})
subswarm.feed.on('unwant', function () {
self.prioritized--
if (!self.prioritized) subswarm.fetch()
})
subswarm.feed.on('put', function (block) {

@@ -60,2 +71,5 @@ for (var i = 0; i < subswarm.peers.length; i++) {

function chooseBlock (peer) {
// TODO: maintain a bitfield of perswarm blocks in progress
// so we wont fetch the same data from multiple peers
var len = peer.remoteBitfield.buffer.length * 8

@@ -73,3 +87,8 @@ var block = -1

var offset = (Math.random() * len) | 0
// TODO: there might be a starvation convern here. should only return *if* there are peers that
// that could satisfy the want list. this is just a quick "hack" for realtime prioritization
// when dealing with multiple files
if (self.prioritized && !subswarm.feed.want.length) return -1
var offset = subswarm.feed.want.length ? subswarm.feed.want[0].block : ((Math.random() * len) | 0)
for (var i = 0; i < len; i++) {

@@ -79,2 +98,3 @@ block = (offset + i) % len

if (peer.remoteBitfield.get(block) && !subswarm.feed.bitfield.get(block)) {
debug('[%s] choosing unprioritized block #%d', self.name, block)
return block

@@ -81,0 +101,0 @@ }

2

package.json
{
"name": "hyperdrive",
"version": "1.3.0",
"version": "1.3.1",
"description": "A file sharing network based on rabin file chunking and append only feeds of data verified by merkle trees.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc