-
Notifications
You must be signed in to change notification settings - Fork 19
/
providers.go
78 lines (74 loc) · 2.98 KB
/
providers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (C) 2023 Gobalsky Labs Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package snapshot
import (
"code.vegaprotocol.io/vega/core/types"
)
// providersInCallOrder holds the providers namespace in the order in which
// they must be called.
var providersInCallOrder = []types.SnapshotNamespace{
types.EpochSnapshot,
types.AssetsSnapshot, // Needs to happen before banking.
types.WitnessSnapshot, // Needs to happen before banking and governance.
types.NetParamsSnapshot,
types.GovernanceSnapshot,
types.BankingSnapshot,
types.CollateralSnapshot,
types.TopologySnapshot,
types.NotarySnapshot,
types.CheckpointSnapshot,
types.DelegationSnapshot,
types.FloatingPointConsensusSnapshot, // Shouldn't matter but maybe best before the markets are restored.
types.ExecutionSnapshot, // Creates the markets, returns matching and positions engines for state providers.
types.MatchingSnapshot, // Requires markets.
types.PositionsSnapshot, // Requires markets.
types.SettlementSnapshot, // Requires markets.
types.LiquidationSnapshot, // Requires markets.
types.HoldingAccountTrackerSnapshot,
types.EthereumOracleVerifierSnapshot,
types.L2EthereumOraclesSnapshot,
types.LiquiditySnapshot,
types.LiquidityV2Snapshot,
types.LiquidityTargetSnapshot,
types.StakingSnapshot,
types.StakeVerifierSnapshot,
types.SpamSnapshot,
types.LimitSnapshot,
types.RewardSnapshot,
types.EventForwarderSnapshot,
types.MarketActivityTrackerSnapshot,
types.ERC20MultiSigTopologySnapshot,
types.EVMMultiSigTopologiesSnapshot,
types.EVMMultiSigTopologiesSnapshot,
types.PoWSnapshot,
types.ProtocolUpgradeSnapshot,
types.TeamsSnapshot,
types.VestingSnapshot,
types.ReferralProgramSnapshot,
types.ActivityStreakSnapshot,
types.VolumeDiscountProgramSnapshot,
types.PartiesSnapshot,
}
func groupPayloadsPerNamespace(payloads []*types.Payload) map[types.SnapshotNamespace][]*types.Payload {
payloadsPerNamespace := make(map[types.SnapshotNamespace][]*types.Payload, len(providersInCallOrder))
for _, payload := range payloads {
providerNamespace := payload.Namespace()
if _, ok := payloadsPerNamespace[providerNamespace]; !ok {
payloadsPerNamespace[providerNamespace] = []*types.Payload{}
}
payloadsPerNamespace[providerNamespace] = append(payloadsPerNamespace[providerNamespace], payload)
}
return payloadsPerNamespace
}