func (s *ShardSyncManager) AddBlock(block *primitives.ShardBlock, newTip bool) {
	slot := block.Header.Slot

	if !newTip {
		return
	}

	for proposalSlot, mgr := range s.slotProposals {
		mgr.lock.Lock()
		if slot < proposalSlot && !mgr.bestProposal.TransactionPackage.StartRoot.IsEqual(&block.Header.StateRoot) {
			mgr.bestProposal = &ProposalInformation{
				TransactionPackage: primitives.TransactionPackage{
					StartRoot:     block.Header.StateRoot,
					EndRoot:       block.Header.StateRoot,
					Updates:       nil,
					Verifications: nil,
					Transactions:  nil,
				},
				startSlot: block.Header.Slot,
			}
		}
		mgr.lock.Unlock()
	}

	for proposalSlot, mgr := range s.slotProposals {
		if slot >= proposalSlot-1 {
			// TODO: improve?
			time.Sleep(200 * time.Millisecond)

			mgr.RequestPackages(block.Header.StateRoot)
		}
	}
}
// AddBlock is a notifee from the manager when a block is added.
AddBlock is a notifee from the manager when a block is added.
// AddBlock is a notifee from the manager when a block is added .
func (s *ShardSyncManager) AddBlock(block *primitives.ShardBlock, newTip bool) {
	slot := block.Header.Slot
	if !newTip {
		return
	}
	for proposalSlot, mgr := range s.slotProposals {
		mgr.lock.Lock()
		if slot < proposalSlot && !mgr.bestProposal.TransactionPackage.StartRoot.IsEqual(&block.Header.StateRoot) {
			mgr.bestProposal = &ProposalInformation{
				TransactionPackage: primitives.TransactionPackage{
					StartRoot:     block.Header.StateRoot,
					EndRoot:       block.Header.StateRoot,
					Updates:       nil,
					Verifications: nil,
					Transactions:  nil,
				},
				startSlot: block.Header.Slot,
			}
		}
		mgr.lock.Unlock()
	}
	for proposalSlot, mgr := range s.slotProposals {
		if slot >= proposalSlot-1 {
			time.Sleep(200 * time.Millisecond)
			mgr.RequestPackages(block.Header.StateRoot)
		}
	}
}
func ( s * ShardSyncManager ) AddBlock ( block * primitives . ShardBlock , newTip bool ) { slot := block . Header . Slot if ! newTip { return } for proposalSlot , mgr := range s . slotProposals { mgr . lock . Lock ( ) if slot < proposalSlot && ! mgr . bestProposal . TransactionPackage . StartRoot . IsEqual ( & block . Header . StateRoot ) { mgr . bestProposal = & ProposalInformation { TransactionPackage : primitives . TransactionPackage { StartRoot : block . Header . StateRoot , EndRoot : block . Header . StateRoot , Updates : nil , Verifications : nil , Transactions : nil , } , startSlot : block . Header . Slot , } } mgr . lock . Unlock ( ) } for proposalSlot , mgr := range s . slotProposals { if slot >= proposalSlot - 1 { time . Sleep ( 200 * time . Millisecond ) mgr . RequestPackages ( block . Header . StateRoot ) } } }
AddBlock is a notifee from the manager when a block is added.
AddBlock is a notifee from the manager when a block is added .
// TODO: improve?