kappa-db / multifeed

Multi-writer hypercore.
135 stars 27 forks source link

fix: unshift leftover data back onto the stream, NOT push #14

Closed hackergrrl closed 5 years ago

hackergrrl commented 5 years ago

This covers the case where

  1. I read a chunk from the through stream, parse the header, and have some leftover data from after the header
  2. the through stream has some MORE buffered data already in it (maybe hypercore-protocol data)
  3. the old code would push the leftover data, which would actually put the beginning of the post-header data AFTER whatever else was already in the stream
  4. this would confuse/break hypercore-protocol, and no replication would happen