Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

wip: use content-decider to control what you replicate #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

olizilla
Copy link
Member

@olizilla olizilla commented Jul 3, 2019

first step on the road to implmenting @ianjdarrow's https://github.com/ianjdarrow/content-decider (thanks @mikeal ;-)

@olizilla
Copy link
Member Author

olizilla commented Jul 3, 2019

See also ipfs/notes#284

async putMany (blocks) {
if (this._decider) {
blocks = blocks.map(b => this._decider(b).then(allowed => allowed ? block : null))
blocks = (await Promise.all(blocks)).filter(x => x)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: .filter(x => x) can also be written as .filter(Boolean).

@@ -13,9 +13,10 @@ class BlockService {
*
* @param {IPFSRepo} ipfsRepo
*/
constructor (ipfsRepo) {
constructor (ipfsRepo, decider) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is optional can it please go in an options object?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants