mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 16:15:17 +00:00
general fixes
This commit is contained in:
parent
19bd01e184
commit
5073df60fc
@ -170,6 +170,17 @@ func (e *MasterClockConsensusEngine) Start() <-chan error {
|
||||
|
||||
e.state = consensus.EngineStateCollecting
|
||||
|
||||
go func() {
|
||||
for {
|
||||
e.logger.Info(
|
||||
"peers in store",
|
||||
zap.Int("peer_store_count", e.pubSub.GetPeerstoreCount()),
|
||||
zap.Int("network_peer_count", e.pubSub.GetNetworkPeersCount()),
|
||||
)
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
for e.state < consensus.EngineStateStopping {
|
||||
var err error
|
||||
|
@ -28,6 +28,7 @@ type BlossomSub struct {
|
||||
logger *zap.Logger
|
||||
peerID peer.ID
|
||||
bitmaskMap map[string]*blossomsub.Bitmask
|
||||
h host.Host
|
||||
}
|
||||
|
||||
var _ PubSub = (*BlossomSub)(nil)
|
||||
@ -107,6 +108,7 @@ func NewBlossomSub(
|
||||
logger,
|
||||
peerID,
|
||||
make(map[string]*blossomsub.Bitmask),
|
||||
h,
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,6 +260,14 @@ func initDHT(
|
||||
return kademliaDHT
|
||||
}
|
||||
|
||||
func (b *BlossomSub) GetPeerstoreCount() int {
|
||||
return len(b.h.Peerstore().Peers())
|
||||
}
|
||||
|
||||
func (b *BlossomSub) GetNetworkPeersCount() int {
|
||||
return len(b.h.Network().Peers())
|
||||
}
|
||||
|
||||
func discoverPeers(
|
||||
p2pConfig *config.P2PConfig,
|
||||
ctx context.Context,
|
||||
@ -276,6 +286,7 @@ func discoverPeers(
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for peer := range peerChan {
|
||||
if peer.ID == h.ID() {
|
||||
continue
|
||||
|
@ -10,5 +10,7 @@ type PubSub interface {
|
||||
Subscribe(bitmask []byte, handler func(message *pb.Message) error, raw bool)
|
||||
Unsubscribe(bitmask []byte, raw bool)
|
||||
GetPeerID() []byte
|
||||
GetPeerstoreCount() int
|
||||
GetNetworkPeersCount() int
|
||||
GetRandomPeer(bitmask []byte) ([]byte, error)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/cockroachdb/pebble"
|
||||
"github.com/iden3/go-iden3-crypto/poseidon"
|
||||
"github.com/pkg/errors"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -131,6 +132,16 @@ func (p *PebbleMasterClockIterator) Value() (*protobufs.ClockFrame, error) {
|
||||
frame.Input = value[4 : len(value)-516]
|
||||
frame.Output = value[len(value)-516:]
|
||||
|
||||
previousSelectorBytes := [516]byte{}
|
||||
copy(previousSelectorBytes[:], frame.Input[:516])
|
||||
|
||||
parent, err := poseidon.HashBytes(previousSelectorBytes[:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get master clock frame iterator value")
|
||||
}
|
||||
|
||||
frame.ParentSelector = parent.Bytes()
|
||||
|
||||
return frame, nil
|
||||
}
|
||||
|
||||
@ -415,6 +426,16 @@ func (p *PebbleClockStore) GetMasterClockFrame(
|
||||
frame.Input = value[4 : len(value)-516]
|
||||
frame.Output = value[len(value)-516:]
|
||||
|
||||
previousSelectorBytes := [516]byte{}
|
||||
copy(previousSelectorBytes[:], frame.Input[:516])
|
||||
|
||||
parent, err := poseidon.HashBytes(previousSelectorBytes[:])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get master clock frame")
|
||||
}
|
||||
|
||||
frame.ParentSelector = parent.Bytes()
|
||||
|
||||
return frame, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user