func (s *SyncManager) ListenForBlocks() error {
	_, err := s.hostNode.SubscribeMessage("block", func(data []byte, from peer.ID) {
		blockProto := new(pb.Block)

		err := proto.Unmarshal(data, blockProto)
		if err != nil {
			logrus.Error(err)
			return
		}

		block, err := primitives.BlockFromProto(blockProto)
		if err != nil {
			logrus.Error(err)
			return
		}

		err = s.handleReceivedBlock(block, from, true)
		if err != nil {
			logrus.Error(err)
			return
		}
	})
	if err != nil {
		return err
	}

	return nil
}
// ListenForBlocks listens for new blocks over the pub-sub network
// being broadcast as a result of finding them.
ListenForBlocks listens for new blocks over the pub-sub network
being broadcast as a result of finding them.
// ListenForBlocks listens for new blocks over the pub - sub network // being broadcast as a result of finding them .
func (s *SyncManager) ListenForBlocks() error {
	_, err := s.hostNode.SubscribeMessage("block", func(data []byte, from peer.ID) {
		blockProto := new(pb.Block)
		err := proto.Unmarshal(data, blockProto)
		if err != nil {
			logrus.Error(err)
			return
		}
		block, err := primitives.BlockFromProto(blockProto)
		if err != nil {
			logrus.Error(err)
			return
		}
		err = s.handleReceivedBlock(block, from, true)
		if err != nil {
			logrus.Error(err)
			return
		}
	})
	if err != nil {
		return err
	}
	return nil
}
func ( s * SyncManager ) ListenForBlocks ( ) error { _ , err := s . hostNode . SubscribeMessage ( " " , func ( data [ ] byte , from peer . ID ) { blockProto := new ( pb . Block ) err := proto . Unmarshal ( data , blockProto ) if err != nil { logrus . Error ( err ) return } block , err := primitives . BlockFromProto ( blockProto ) if err != nil { logrus . Error ( err ) return } err = s . handleReceivedBlock ( block , from , true ) if err != nil { logrus . Error ( err ) return } } ) if err != nil { return err } return nil }
ListenForBlocks listens for new blocks over the pub-sub network
being broadcast as a result of finding them.
ListenForBlocks listens for new blocks over the pub - sub network being broadcast as a result of finding them .