Giter VIP home page Giter VIP logo

Comments (7)

wemeetagain avatar wemeetagain commented on July 19, 2024

I'm thinking of doing something like this in our gossipsub impl in lodestar.
eg:

class LodestarGossipSub extends Gossipsub {
  // fancy features
}

Pubsub/Gossipsub provides a validate(message): boolean that we can/will need to overload that gets called in the right spot.

from js-libp2p-gossipsub.

mpetrunic avatar mpetrunic commented on July 19, 2024

Pubsub/Gossipsub provides a validate(message): boolean that we can/will need to overload that gets called in the right spot.

That was my first idea, but then we would have to decode message twice. First time in validate, second time when event is received.
Other problem is that in validate we don't know the topic and thus we don't know how to decode message.

from js-libp2p-gossipsub.

wemeetagain avatar wemeetagain commented on July 19, 2024

The decoding twice thing is definitely not ideal. We might want to tweak things there.

RE not knowing the topic, the message object that validate receives has a list of topics attached, so we can dispatch to a topic-specific validating function if we have it around.
eg something like:

interface Message {
  from?: Buffer;
  data?: Buffer;
  seqno?: Buffer;
  topicIDs: string[];
  signature?: Buffer;
  key?: Buffer;
}
class MyGossip {
  topicValidators: Map<string, (message: Message): boolean>;
  validate(message: Message): boolean {
    return message.topicIDs
      .map(topic => this.topicValidators.get(topic))
      .every(validator=> !validator || validator(message));
  } 
}

from js-libp2p-gossipsub.

stale avatar stale commented on July 19, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

from js-libp2p-gossipsub.

twoeths avatar twoeths commented on July 19, 2024

Unstale

from js-libp2p-gossipsub.

stale avatar stale commented on July 19, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

from js-libp2p-gossipsub.

twoeths avatar twoeths commented on July 19, 2024

This issue was done.

from js-libp2p-gossipsub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.