mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-26 00:25:17 +00:00
v1.4.15 (#158)
This commit is contained in:
parent
4148de06bd
commit
150020231a
@ -10,11 +10,11 @@ func GetMinimumVersionCutoff() time.Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetMinimumVersion() []byte {
|
func GetMinimumVersion() []byte {
|
||||||
return []byte{0x01, 0x04, 0x0E}
|
return []byte{0x01, 0x04, 0x0F}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetVersion() []byte {
|
func GetVersion() []byte {
|
||||||
return []byte{0x01, 0x04, 0x0E}
|
return []byte{0x01, 0x04, 0x0F}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetVersionString() string {
|
func GetVersionString() string {
|
||||||
|
@ -160,11 +160,44 @@ func NewBlossomSub(
|
|||||||
}
|
}
|
||||||
|
|
||||||
blossomOpts := []blossomsub.Option{}
|
blossomOpts := []blossomsub.Option{}
|
||||||
|
if isBootstrapPeer {
|
||||||
|
blossomOpts = append(blossomOpts,
|
||||||
|
blossomsub.WithPeerExchange(true),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if tracer != nil {
|
if tracer != nil {
|
||||||
blossomOpts = append(blossomOpts, blossomsub.WithEventTracer(tracer))
|
blossomOpts = append(blossomOpts, blossomsub.WithEventTracer(tracer))
|
||||||
}
|
}
|
||||||
|
blossomOpts = append(blossomOpts, blossomsub.WithPeerScore(
|
||||||
|
&blossomsub.PeerScoreParams{
|
||||||
|
SkipAtomicValidation: false,
|
||||||
|
BitmaskScoreCap: 0,
|
||||||
|
IPColocationFactorWeight: 0,
|
||||||
|
IPColocationFactorThreshold: 6,
|
||||||
|
BehaviourPenaltyWeight: 0,
|
||||||
|
BehaviourPenaltyThreshold: 100,
|
||||||
|
BehaviourPenaltyDecay: .5,
|
||||||
|
DecayInterval: 10 * time.Second,
|
||||||
|
DecayToZero: .1,
|
||||||
|
RetainScore: 5 * time.Minute,
|
||||||
|
AppSpecificScore: func(p peer.ID) float64 {
|
||||||
|
return float64(bs.GetPeerScore([]byte(p)))
|
||||||
|
},
|
||||||
|
AppSpecificWeight: 10.0,
|
||||||
|
},
|
||||||
|
&blossomsub.PeerScoreThresholds{
|
||||||
|
SkipAtomicValidation: false,
|
||||||
|
GossipThreshold: -2000,
|
||||||
|
PublishThreshold: -5000,
|
||||||
|
GraylistThreshold: -10000,
|
||||||
|
AcceptPXThreshold: 100,
|
||||||
|
OpportunisticGraftThreshold: 2,
|
||||||
|
}))
|
||||||
|
|
||||||
ps, err := blossomsub.NewFloodSub(ctx, h, blossomOpts...)
|
params := mergeDefaults(p2pConfig)
|
||||||
|
rt := blossomsub.NewBlossomSubRouter(h, params)
|
||||||
|
ps, err := blossomsub.NewBlossomSubWithRouter(ctx, h, rt, blossomOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -312,26 +345,33 @@ func initDHT(
|
|||||||
}
|
}
|
||||||
|
|
||||||
reconnect := func() {
|
reconnect := func() {
|
||||||
var wg sync.WaitGroup
|
|
||||||
|
|
||||||
logger.Info(
|
logger.Info(
|
||||||
"connecting to bootstrap",
|
"connecting to bootstrap",
|
||||||
zap.String("peer_id", h.ID().String()),
|
zap.String("peer_id", h.ID().String()),
|
||||||
)
|
)
|
||||||
|
|
||||||
defaultBootstrapPeers := p2pConfig.BootstrapPeers
|
defaultBootstrapPeers := p2pConfig.BootstrapPeers
|
||||||
|
connected := 0
|
||||||
|
|
||||||
for _, peerAddr := range defaultBootstrapPeers {
|
for connected < 2 {
|
||||||
|
i, err := rand.Int(
|
||||||
|
rand.Reader,
|
||||||
|
big.NewInt(int64(len(defaultBootstrapPeers))),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
peerAddr := defaultBootstrapPeers[i.Int64()]
|
||||||
peerinfo, err := peer.AddrInfoFromString(peerAddr)
|
peerinfo, err := peer.AddrInfoFromString(peerAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
|
||||||
go func() {
|
|
||||||
defer wg.Done()
|
|
||||||
if peerinfo.ID == h.ID() ||
|
if peerinfo.ID == h.ID() ||
|
||||||
h.Network().Connectedness(peerinfo.ID) == network.Connected {
|
h.Network().Connectedness(peerinfo.ID) == network.Connected ||
|
||||||
return
|
connected >= 2 {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := h.Connect(ctx, *peerinfo); err != nil {
|
if err := h.Connect(ctx, *peerinfo); err != nil {
|
||||||
@ -341,10 +381,9 @@ func initDHT(
|
|||||||
"connected to peer",
|
"connected to peer",
|
||||||
zap.String("peer_id", peerinfo.ID.String()),
|
zap.String("peer_id", peerinfo.ID.String()),
|
||||||
)
|
)
|
||||||
|
connected++
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect()
|
reconnect()
|
||||||
@ -354,7 +393,7 @@ func initDHT(
|
|||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
// try to assert some stability, never go below min peers for data
|
// try to assert some stability, never go below min peers for data
|
||||||
// consensus:
|
// consensus:
|
||||||
if len(h.Network().Peers()) < 4 {
|
if len(h.Network().Peers()) < 2 {
|
||||||
logger.Info("reconnecting to peers")
|
logger.Info("reconnecting to peers")
|
||||||
reconnect()
|
reconnect()
|
||||||
}
|
}
|
||||||
@ -554,8 +593,10 @@ func discoverPeers(
|
|||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(5 * time.Minute)
|
time.Sleep(5 * time.Minute)
|
||||||
|
if len(h.Network().Peers()) < 4 {
|
||||||
discover()
|
discover()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
logger.Info("completed initial peer discovery")
|
logger.Info("completed initial peer discovery")
|
||||||
|
Loading…
Reference in New Issue
Block a user