Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritise json for staking max electing voters 86935m0yc #891

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ struct ChainModel: Equatable, Codable, Hashable {
var isUtilityTokenOnRelaychain: Bool {
additional?.relaychainAsNative?.boolValue ?? false
}

var stakingMaxElectingVoters: UInt32? {
guard let value = additional?.stakingMaxElectingVoters?.unsignedIntValue else {
return nil
}

return UInt32(value)
}
}

extension ChainModel: Identifiable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import SubstrateSdk

protocol RelaychainConsensusStateDepending {
func createNetworkInfoOperationFactory(
for durationFactory: StakingDurationOperationFactoryProtocol,
for chain: ChainModel,
durationFactory: StakingDurationOperationFactoryProtocol,
operationQueue: OperationQueue
) -> NetworkStakingInfoOperationFactoryProtocol

Expand All @@ -22,10 +23,12 @@ protocol RelaychainConsensusStateDepending {

final class RelaychainConsensusStateDependingFactory: RelaychainConsensusStateDepending {
func createNetworkInfoOperationFactory(
for durationFactory: StakingDurationOperationFactoryProtocol,
for chain: ChainModel,
durationFactory: StakingDurationOperationFactoryProtocol,
operationQueue: OperationQueue
) -> NetworkStakingInfoOperationFactoryProtocol {
let votersInfoOperationFactory = VotersInfoOperationFactory(
chain: chain,
operationManager: OperationManager(operationQueue: operationQueue)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ final class RelaychainStakingSharedState: RelaychainStakingSharedStateProtocol {
)

return consensusDependingFactory.createNetworkInfoOperationFactory(
for: durationFactory,
for: stakingOption.chainAsset.chain,
durationFactory: durationFactory,
operationQueue: operationQueue
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ final class RelaychainStartStakingState: RelaychainStartStakingStateProtocol {
)

return consensusDependingFactory.createNetworkInfoOperationFactory(
for: durationFactory,
for: chainAsset.chain,
durationFactory: durationFactory,
operationQueue: operationQueue
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ protocol VotersInfoOperationFactoryProtocol {

final class VotersInfoOperationFactory {
let operationManager: OperationManagerProtocol
let chain: ChainModel

init(operationManager: OperationManagerProtocol) {
init(chain: ChainModel, operationManager: OperationManagerProtocol) {
self.operationManager = operationManager
self.chain = chain
}

private func createBagsListResolutionOperation(
Expand Down Expand Up @@ -54,6 +56,10 @@ final class VotersInfoOperationFactory {
private func createMaxElectingVotersOperation(
dependingOn codingFactoryOperation: BaseOperation<RuntimeCoderFactoryProtocol>
) -> BaseOperation<UInt32> {
if let maxElectingVoter = chain.stakingMaxElectingVoters {
return BaseOperation.createWithResult(maxElectingVoter)
}

let valueOperation = PrimitiveConstantOperation<UInt32>(
path: ElectionProviderMultiPhase.maxElectingVoters,
fallbackValue: UInt32.max
Expand Down
Loading