func (sm *ShardManager) ListenForNewCrosslinks() {
	go func() {
		stream, err := sm.BeaconClient.CrosslinkStream(context.Background(), &pb.CrosslinkStreamRequest{
			ShardID: uint64(sm.shardInfo.ShardID),
		})
		if err != nil {
			logrus.Error(err)
		}

		for {
			newCrosslink, err := stream.Recv()
			if err != nil {
				logrus.Error(err)
				break
			}

			crosslinkHash, err := chainhash.NewHash(newCrosslink.BlockHash)
			if err != nil {
				logrus.Error(err)
				break
			}

			finalizedNode, err := sm.Index.GetNodeByHash(crosslinkHash)
			if err != nil {
				logrus.Error(err)
				break
			}

			for _, n := range sm.notifees {
				n.FinalizeBlockHash(*crosslinkHash, newCrosslink.Slot)
			}

			if err := sm.stateManager.Finalize(*crosslinkHash, finalizedNode.Slot); err != nil {
				logrus.Error(err, sm.InitializationParameters.RootBlockHash)
				break
			}
			// TODO: also update fork choice with new crosslink
		}
	}()
}
// ListenForNewCrosslinks listens for new crosslinks.
ListenForNewCrosslinks listens for new crosslinks.
// ListenForNewCrosslinks listens for new crosslinks .
func (sm *ShardManager) ListenForNewCrosslinks() {
	go func() {
		stream, err := sm.BeaconClient.CrosslinkStream(context.Background(), &pb.CrosslinkStreamRequest{
			ShardID: uint64(sm.shardInfo.ShardID),
		})
		if err != nil {
			logrus.Error(err)
		}
		for {
			newCrosslink, err := stream.Recv()
			if err != nil {
				logrus.Error(err)
				break
			}
			crosslinkHash, err := chainhash.NewHash(newCrosslink.BlockHash)
			if err != nil {
				logrus.Error(err)
				break
			}
			finalizedNode, err := sm.Index.GetNodeByHash(crosslinkHash)
			if err != nil {
				logrus.Error(err)
				break
			}
			for _, n := range sm.notifees {
				n.FinalizeBlockHash(*crosslinkHash, newCrosslink.Slot)
			}
			if err := sm.stateManager.Finalize(*crosslinkHash, finalizedNode.Slot); err != nil {
				logrus.Error(err, sm.InitializationParameters.RootBlockHash)
				break
			}
		}
	}()
}
func ( sm * ShardManager ) ListenForNewCrosslinks ( ) { go func ( ) { stream , err := sm . BeaconClient . CrosslinkStream ( context . Background ( ) , & pb . CrosslinkStreamRequest { ShardID : uint64 ( sm . shardInfo . ShardID ) , } ) if err != nil { logrus . Error ( err ) } for { newCrosslink , err := stream . Recv ( ) if err != nil { logrus . Error ( err ) break } crosslinkHash , err := chainhash . NewHash ( newCrosslink . BlockHash ) if err != nil { logrus . Error ( err ) break } finalizedNode , err := sm . Index . GetNodeByHash ( crosslinkHash ) if err != nil { logrus . Error ( err ) break } for _ , n := range sm . notifees { n . FinalizeBlockHash ( * crosslinkHash , newCrosslink . Slot ) } if err := sm . stateManager . Finalize ( * crosslinkHash , finalizedNode . Slot ) ; err != nil { logrus . Error ( err , sm . InitializationParameters . RootBlockHash ) break } } } ( ) }
ListenForNewCrosslinks listens for new crosslinks.
ListenForNewCrosslinks listens for new crosslinks .
// TODO: also update fork choice with new crosslink