Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Upgrade libp2p and fix dropped message issue in gossip #312

Merged
merged 3 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/btcsuite/btcd v0.21.0-beta
github.com/go-kit/kit v0.9.0
github.com/golang/protobuf v1.5.2
github.com/google/gopacket v1.1.18 // indirect
github.com/google/uuid v1.1.4
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/go-hclog v0.16.2
Expand All @@ -17,11 +16,11 @@ require (
github.com/hashicorp/hcl v1.0.0
github.com/hashicorp/vault/api v1.3.0
github.com/imdario/mergo v0.3.7
github.com/libp2p/go-libp2p v0.12.0
github.com/libp2p/go-libp2p-core v0.7.0
github.com/libp2p/go-libp2p v0.14.0
github.com/libp2p/go-libp2p-core v0.8.5
github.com/libp2p/go-libp2p-kbucket v0.4.7
github.com/libp2p/go-libp2p-noise v0.1.1
github.com/libp2p/go-libp2p-pubsub v0.4.1
github.com/libp2p/go-libp2p-noise v0.2.0
github.com/libp2p/go-libp2p-pubsub v0.5.0
github.com/mitchellh/cli v1.0.0
github.com/multiformats/go-multiaddr v0.3.1
github.com/prometheus/client_golang v1.4.0
Expand Down
231 changes: 231 additions & 0 deletions go.sum

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions network/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"google.golang.org/protobuf/proto"
)

const (
bufferSize = 512 // buffer size of gossip queue
)

type Topic struct {
logger hclog.Logger

Expand All @@ -31,7 +35,7 @@ func (t *Topic) Publish(obj proto.Message) error {
}

func (t *Topic) Subscribe(handler func(obj interface{})) error {
sub, err := t.topic.Subscribe()
sub, err := t.topic.Subscribe(pubsub.WithBufferSize(bufferSize))
if err != nil {
return err
}
Expand All @@ -54,13 +58,14 @@ func (t *Topic) readLoop(sub *pubsub.Subscription, handler func(obj interface{})
t.logger.Error("failed to get topic", "err", err)
continue
}

obj := t.createObj()
if err := proto.Unmarshal(msg.Data, obj); err != nil {
t.logger.Error("failed to unmarshal topic", "err", err)
continue
}
handler(obj)
go func() {
obj := t.createObj()
if err := proto.Unmarshal(msg.Data, obj); err != nil {
t.logger.Error("failed to unmarshal topic", "err", err)
return
}
handler(obj)
}()
}
}

Expand Down
10 changes: 0 additions & 10 deletions vendor/github.com/flynn/noise/.travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions vendor/github.com/flynn/noise/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 10 additions & 11 deletions vendor/github.com/flynn/noise/cipher_suite.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vendor/github.com/flynn/noise/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/flynn/noise/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/flynn/noise/patterns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading