Skip to content

Commit

Permalink
refactor: remove unused selection factory (#3180)
Browse files Browse the repository at this point in the history
This commit cleansup the broadcaster and NewSessionManager code by
removing the selection factory that has been unused since
fea5673.
  • Loading branch information
rickstaa authored Sep 23, 2024
1 parent 81bc9e5 commit aad1a23
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion server/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ func (bsm *BroadcastSessionsManager) shouldSkipVerification(sessions []*Broadcas
return common.RandomUintUnder(bsm.VerificationFreq) != 0
}

func NewSessionManager(ctx context.Context, node *core.LivepeerNode, params *core.StreamParameters, sel BroadcastSessionsSelectorFactory) *BroadcastSessionsManager {
func NewSessionManager(ctx context.Context, node *core.LivepeerNode, params *core.StreamParameters) *BroadcastSessionsManager {
if node.Capabilities != nil {
params.Capabilities.SetMinVersionConstraint(node.Capabilities.MinVersionConstraint())
}
Expand Down
8 changes: 2 additions & 6 deletions server/broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ func StubBroadcastSession(transcoder string) *BroadcastSession {
}
}

func selFactoryEmpty() BroadcastSessionsSelector {
return &LIFOSelector{}
}

func bsmWithSessList(sessList []*BroadcastSession) *BroadcastSessionsManager {
return bsmWithSessListExt(sessList, nil, false)
}
Expand Down Expand Up @@ -299,7 +295,7 @@ func TestNewSessionManager(t *testing.T) {

// Check empty pool produces expected numOrchs

sess := NewSessionManager(context.TODO(), n, params, selFactoryEmpty)
sess := NewSessionManager(context.TODO(), n, params)
assert.Equal(0, sess.trustedPool.numOrchs)
assert.Equal(0, sess.untrustedPool.numOrchs)

Expand All @@ -308,7 +304,7 @@ func TestNewSessionManager(t *testing.T) {
n.OrchestratorPool = sd
max := int(common.HTTPTimeout.Seconds()/SegLen.Seconds()) * 2
for i := 0; i < 10; i++ {
sess = NewSessionManager(context.TODO(), n, params, selFactoryEmpty)
sess = NewSessionManager(context.TODO(), n, params)
if i < max {
assert.Equal(i, sess.trustedPool.numOrchs)
} else {
Expand Down
11 changes: 1 addition & 10 deletions server/mediaserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,8 @@ func (s *LivepeerServer) registerConnection(ctx context.Context, rtmpStrm stream
// do not obtain this lock again while initializing channel is open, it will cause deadlock if other goroutine already obtained the lock and called getActiveRtmpConnectionUnsafe()
s.connectionLock.Unlock()

// initialize session manager
var stakeRdr stakeReader
if s.LivepeerNode.Eth != nil {
stakeRdr = &storeStakeReader{store: s.LivepeerNode.Database}
}
selFactory := func() BroadcastSessionsSelector {
return NewMinLSSelector(stakeRdr, SELECTOR_LATENCY_SCORE_THRESHOLD, s.LivepeerNode.SelectionAlgorithm, s.LivepeerNode.OrchPerfScore)
}

// safe, because other goroutines should be waiting on initializing channel
cxn.sessManager = NewSessionManager(ctx, s.LivepeerNode, params, selFactory)
cxn.sessManager = NewSessionManager(ctx, s.LivepeerNode, params)

// populate fields and signal initializing channel
s.serverLock.Lock()
Expand Down

0 comments on commit aad1a23

Please sign in to comment.