vet
used for range variable inside goroutine, now passed as argument
This commit is contained in:
parent
1945f895a2
commit
7dd4e0bfeb
6
comm.go
6
comm.go
|
@ -7,9 +7,9 @@ import (
|
||||||
|
|
||||||
pb "github.com/libp2p/go-floodsub/pb"
|
pb "github.com/libp2p/go-floodsub/pb"
|
||||||
|
|
||||||
ggio "github.com/gogo/protobuf/io"
|
inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net"
|
||||||
proto "github.com/gogo/protobuf/proto"
|
ggio "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/io"
|
||||||
inet "github.com/libp2p/go-libp2p-net"
|
proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// get the initial RPC containing all of our subscriptions to send to new peers
|
// get the initial RPC containing all of our subscriptions to send to new peers
|
||||||
|
|
16
floodsub.go
16
floodsub.go
|
@ -9,12 +9,12 @@ import (
|
||||||
|
|
||||||
pb "github.com/libp2p/go-floodsub/pb"
|
pb "github.com/libp2p/go-floodsub/pb"
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log"
|
inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net"
|
||||||
host "github.com/libp2p/go-libp2p-host"
|
logging "gx/ipfs/QmSpJByNKFX1sCsHBEp3R73FL4NF6FnQTEGyNAXHm2GS52/go-log"
|
||||||
inet "github.com/libp2p/go-libp2p-net"
|
peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
timecache "gx/ipfs/QmYftoT56eEfUBTD3erR6heXuPSUhGRezSmhSU8LeczP8b/timecache"
|
||||||
protocol "github.com/libp2p/go-libp2p-protocol"
|
protocol "gx/ipfs/QmZNkThpqfVXs9GNbexPrfBbXSLNYeKrE7jwFM2oqHbyqN/go-libp2p-protocol"
|
||||||
timecache "github.com/whyrusleeping/timecache"
|
host "gx/ipfs/Qmc1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk/go-libp2p-host"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ID = protocol.ID("/floodsub/1.0.0")
|
const ID = protocol.ID("/floodsub/1.0.0")
|
||||||
|
@ -328,14 +328,14 @@ func (p *PubSub) handleIncomingRPC(rpc *RPC) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
subs := p.getSubscriptions(&Message{pmsg}) // call before goroutine!
|
subs := p.getSubscriptions(&Message{pmsg}) // call before goroutine!
|
||||||
go func() {
|
go func(pmsg *pb.Message) {
|
||||||
if p.validate(subs, &Message{pmsg}) {
|
if p.validate(subs, &Message{pmsg}) {
|
||||||
p.sendMsg <- sendReq{
|
p.sendMsg <- sendReq{
|
||||||
from: rpc.from,
|
from: rpc.from,
|
||||||
msg: &Message{pmsg},
|
msg: &Message{pmsg},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}(pmsg)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,11 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
host "github.com/libp2p/go-libp2p-host"
|
netutil "gx/ipfs/QmQGX417WoxKxDJeHqouMEmmH4G1RCENNSzkZYHrXy3Xb3/go-libp2p-netutil"
|
||||||
netutil "github.com/libp2p/go-libp2p-netutil"
|
peer "gx/ipfs/QmXYjuNuxVzXKJCfWasQk1RqkhVLDM9jtUKhqc2WPQmFSB/go-libp2p-peer"
|
||||||
peer "github.com/libp2p/go-libp2p-peer"
|
host "gx/ipfs/Qmc1XhrFEiSeBNn3mpfg6gEuYCt5im2gYmNVmncsvmpeAk/go-libp2p-host"
|
||||||
//bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
//bhost "github.com/libp2p/go-libp2p/p2p/host/basic"
|
||||||
bhost "github.com/libp2p/go-libp2p-blankhost"
|
bhost "gx/ipfs/QmQkeGXc9ZuQ5upVFpd2EjKvgw9aVh1BbtAgvNGVcebmmX/go-libp2p-blankhost"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkMessageRouting(t *testing.T, topic string, pubs []*PubSub, subs []*Subscription) {
|
func checkMessageRouting(t *testing.T, topic string, pubs []*PubSub, subs []*Subscription) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package floodsub
|
package floodsub
|
||||||
|
|
||||||
import (
|
import (
|
||||||
inet "github.com/libp2p/go-libp2p-net"
|
inet "gx/ipfs/QmNa31VPzC561NWwRsJLE7nGYZYuuD2QfpK2b1q9BK54J1/go-libp2p-net"
|
||||||
ma "github.com/multiformats/go-multiaddr"
|
ma "gx/ipfs/QmXY77cVe7rVRQXZZQRioukUM7aRW3BTcAgJe12MCtb3Ji/go-multiaddr"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ inet.Notifiee = (*PubSubNotif)(nil)
|
var _ inet.Notifiee = (*PubSubNotif)(nil)
|
||||||
|
|
|
@ -15,7 +15,7 @@ It has these top-level messages:
|
||||||
*/
|
*/
|
||||||
package floodsub_pb
|
package floodsub_pb
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "gx/ipfs/QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV/gogo-protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue