Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 874e1ef

Browse files
committed
Create a callback that returns OnlineCommittee size instead of relying on internal implementation details
1 parent 928e923 commit 874e1ef

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

pkg/protocol/engine/ledger/ledger/ledger.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ func NewProvider() module.Provider[*engine.Engine, ledger.Ledger] {
6464

6565
e.Constructed.OnTrigger(func() {
6666
e.Events.Ledger.LinkTo(l.events)
67-
l.spendDAG = spenddagv1.New[iotago.TransactionID, mempool.StateID, ledger.BlockVoteRank](l.sybilProtection.SeatManager().OnlineCommittee().Size)
67+
l.spendDAG = spenddagv1.New[iotago.TransactionID, mempool.StateID, ledger.BlockVoteRank](func() int {
68+
return l.sybilProtection.SeatManager().OnlineCommittee().Size()
69+
})
6870
e.Events.SpendDAG.LinkTo(l.spendDAG.Events())
6971

7072
l.setRetainTransactionFailureFunc(e.Retainer.RetainTransactionFailure)
@@ -111,7 +113,9 @@ func New(
111113
commitmentLoader: commitmentLoader,
112114
sybilProtection: sybilProtection,
113115
errorHandler: errorHandler,
114-
spendDAG: spenddagv1.New[iotago.TransactionID, mempool.StateID, ledger.BlockVoteRank](sybilProtection.SeatManager().OnlineCommittee().Size),
116+
spendDAG: spenddagv1.New[iotago.TransactionID, mempool.StateID, ledger.BlockVoteRank](func() int {
117+
return sybilProtection.SeatManager().OnlineCommittee().Size()
118+
}),
115119
}
116120
}
117121

pkg/protocol/engine/tipselection/v1/provider.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ func NewProvider(opts ...options.Option[TipSelection]) module.Provider[*engine.E
2121
e.Constructed.OnTrigger(func() {
2222
// wait for submodules to be constructed (so all of their properties are available)
2323
module.OnAllConstructed(func() {
24-
t.Construct(e.TipManager, e.Ledger.SpendDAG(), e.Ledger.MemPool().TransactionMetadata, func() iotago.BlockID { return lo.Return1(e.EvictionState.LatestActiveRootBlock()) }, DynamicLivenessThreshold(e.SybilProtection.SeatManager().OnlineCommittee().Size))
24+
t.Construct(e.TipManager, e.Ledger.SpendDAG(), e.Ledger.MemPool().TransactionMetadata, func() iotago.BlockID { return lo.Return1(e.EvictionState.LatestActiveRootBlock()) }, DynamicLivenessThreshold(func() int {
25+
return e.SybilProtection.SeatManager().OnlineCommittee().Size()
26+
}))
2527
}, e.TipManager, e.Ledger, e.SybilProtection)
2628
})
2729

0 commit comments

Comments
 (0)