mirror of
				https://source.quilibrium.com/quilibrium/ceremonyclient.git
				synced 2025-11-04 11:17:28 +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
 | 
						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() {
 | 
						go func() {
 | 
				
			||||||
		for e.state < consensus.EngineStateStopping {
 | 
							for e.state < consensus.EngineStateStopping {
 | 
				
			||||||
			var err error
 | 
								var err error
 | 
				
			||||||
 | 
				
			|||||||
@ -28,6 +28,7 @@ type BlossomSub struct {
 | 
				
			|||||||
	logger     *zap.Logger
 | 
						logger     *zap.Logger
 | 
				
			||||||
	peerID     peer.ID
 | 
						peerID     peer.ID
 | 
				
			||||||
	bitmaskMap map[string]*blossomsub.Bitmask
 | 
						bitmaskMap map[string]*blossomsub.Bitmask
 | 
				
			||||||
 | 
						h          host.Host
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var _ PubSub = (*BlossomSub)(nil)
 | 
					var _ PubSub = (*BlossomSub)(nil)
 | 
				
			||||||
@ -107,6 +108,7 @@ func NewBlossomSub(
 | 
				
			|||||||
		logger,
 | 
							logger,
 | 
				
			||||||
		peerID,
 | 
							peerID,
 | 
				
			||||||
		make(map[string]*blossomsub.Bitmask),
 | 
							make(map[string]*blossomsub.Bitmask),
 | 
				
			||||||
 | 
							h,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -258,6 +260,14 @@ func initDHT(
 | 
				
			|||||||
	return kademliaDHT
 | 
						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(
 | 
					func discoverPeers(
 | 
				
			||||||
	p2pConfig *config.P2PConfig,
 | 
						p2pConfig *config.P2PConfig,
 | 
				
			||||||
	ctx context.Context,
 | 
						ctx context.Context,
 | 
				
			||||||
@ -276,6 +286,7 @@ func discoverPeers(
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			panic(err)
 | 
								panic(err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for peer := range peerChan {
 | 
							for peer := range peerChan {
 | 
				
			||||||
			if peer.ID == h.ID() {
 | 
								if peer.ID == h.ID() {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
 | 
				
			|||||||
@ -10,5 +10,7 @@ type PubSub interface {
 | 
				
			|||||||
	Subscribe(bitmask []byte, handler func(message *pb.Message) error, raw bool)
 | 
						Subscribe(bitmask []byte, handler func(message *pb.Message) error, raw bool)
 | 
				
			||||||
	Unsubscribe(bitmask []byte, raw bool)
 | 
						Unsubscribe(bitmask []byte, raw bool)
 | 
				
			||||||
	GetPeerID() []byte
 | 
						GetPeerID() []byte
 | 
				
			||||||
 | 
						GetPeerstoreCount() int
 | 
				
			||||||
 | 
						GetNetworkPeersCount() int
 | 
				
			||||||
	GetRandomPeer(bitmask []byte) ([]byte, error)
 | 
						GetRandomPeer(bitmask []byte) ([]byte, error)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@ import (
 | 
				
			|||||||
	"encoding/binary"
 | 
						"encoding/binary"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/cockroachdb/pebble"
 | 
						"github.com/cockroachdb/pebble"
 | 
				
			||||||
 | 
						"github.com/iden3/go-iden3-crypto/poseidon"
 | 
				
			||||||
	"github.com/pkg/errors"
 | 
						"github.com/pkg/errors"
 | 
				
			||||||
	"go.uber.org/zap"
 | 
						"go.uber.org/zap"
 | 
				
			||||||
	"google.golang.org/protobuf/proto"
 | 
						"google.golang.org/protobuf/proto"
 | 
				
			||||||
@ -131,6 +132,16 @@ func (p *PebbleMasterClockIterator) Value() (*protobufs.ClockFrame, error) {
 | 
				
			|||||||
	frame.Input = value[4 : len(value)-516]
 | 
						frame.Input = value[4 : len(value)-516]
 | 
				
			||||||
	frame.Output = value[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
 | 
						return frame, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -415,6 +426,16 @@ func (p *PebbleClockStore) GetMasterClockFrame(
 | 
				
			|||||||
	frame.Input = value[4 : len(value)-516]
 | 
						frame.Input = value[4 : len(value)-516]
 | 
				
			||||||
	frame.Output = value[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
 | 
						return frame, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user