Skip to content

Commit

Permalink
Merge branch 'master' into yahya/adds-rpc-inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
yhassanzadeh13 authored Nov 24, 2022
2 parents 6f0858c + 26f8d34 commit 2e13ee8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 7 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Build
run: make build


unittest:
name: Unit Tests
strategy:
fail-fast: false
matrix:
go-version:
- 1.16
runs-on: ubuntu-latest
steps:
- name: Check Go Version
uses: actions/setup-go@v2
with:
go-version: ${{matrix.go-version}}
- name: Checkout repo
uses: actions/checkout@v2
- name: Run tests
run: make test
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
GO111MODULE=on go test ./...
build:
go build -v ./...

5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/libp2p/go-libp2p-pubsub
module github.com/yhassanzadeh13/go-libp2p-pubsub

go 1.17

Expand All @@ -7,6 +7,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/ipfs/go-log v1.0.5
github.com/libp2p/go-libp2p v0.22.0
github.com/libp2p/go-libp2p-pubsub v0.8.1-0.20220908052023-8866ca88a105
github.com/libp2p/go-libp2p-testing v0.12.0
github.com/libp2p/go-msgio v0.2.0
github.com/multiformats/go-multiaddr v0.6.0
Expand Down Expand Up @@ -36,6 +37,7 @@ require (
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-flow-metrics v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.0 // indirect
Expand Down Expand Up @@ -86,7 +88,6 @@ require (
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ github.com/libp2p/go-libp2p v0.22.0 h1:2Tce0kHOp5zASFKJbNzRElvh0iZwdtG5uZheNW8ch
github.com/libp2p/go-libp2p v0.22.0/go.mod h1:UDolmweypBSjQb2f7xutPnwZ/fxioLbMBxSjRksxxU4=
github.com/libp2p/go-libp2p-asn-util v0.2.0/go.mod h1:WoaWxbHKBymSN41hWSq/lGKJEca7TNm58+gGJi2WsLI=
github.com/libp2p/go-libp2p-core v0.19.0/go.mod h1:AkA+FUKQfYt1FLNef5fOPlo/naAWjKy/RCjkcPjqzYg=
github.com/libp2p/go-libp2p-pubsub v0.8.1-0.20220908052023-8866ca88a105 h1:EAAgUl0EnSk4Z/ct1xsHTYSy9JYDdcTazrC6phSdlIY=
github.com/libp2p/go-libp2p-pubsub v0.8.1-0.20220908052023-8866ca88a105/go.mod h1:e4kT+DYjzPUYGZeWk4I+oxCSYTXizzXii5LDRRhjKSw=
github.com/libp2p/go-libp2p-testing v0.11.0/go.mod h1:qG4sF27dfKFoK9KlVzK2y52LQKhp0VEmLjV5aDqr1Hg=
github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
Expand Down
12 changes: 7 additions & 5 deletions gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,12 @@ func (gs *GossipSubRouter) pushControl(p peer.ID, ctl *pb.ControlMessage) {
}
}

// SendControl dispatches the given set of control messages to the given peer.
func (gs *GossipSubRouter) SendControl(p peer.ID, ctl *pb.ControlMessage) {
out := rpcWithControl(nil, ctl.Ihave, ctl.Iwant, ctl.Graft, ctl.Prune)
gs.sendRPC(p, out)
}

func (gs *GossipSubRouter) piggybackControl(p peer.ID, out *RPC, ctl *pb.ControlMessage) {
// check control message for staleness first
var tograft []*pb.ControlGraft
Expand Down Expand Up @@ -1941,11 +1947,7 @@ func (gs *GossipSubRouter) getPeers(topic string, count int, filter func(peer.ID
return peers
}

// WithDefaultTagTracer returns the tag tracer of the GossipSubRouter as a PubSub option.
// This is useful for cases where the GossipSubRouter is instantiated externally, and is
// injected into the GossipSub constructor as a dependency. This allows the tag tracer to be
// also injected into the GossipSub constructor as a PubSub option dependency.
func (gs *GossipSubRouter) WithDefaultTagTracer() Option {
func (gs *GossipSubRouter) WithTagTracerPubsubOption() Option {
return WithRawTracer(gs.tagTracer)
}

Expand Down

0 comments on commit 2e13ee8

Please sign in to comment.