-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathAllNodeDetailsModel.swift
130 lines (107 loc) · 5.46 KB
/
AllNodeDetailsModel.swift
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import Foundation
import BigInt
public struct AllNodeDetailsModel:Equatable, Decodable {
public static func == (lhs : AllNodeDetailsModel, rhs : AllNodeDetailsModel) -> Bool {
return lhs.currentEpoch == rhs.currentEpoch && lhs.torusNodeEndpoints == rhs.torusNodeEndpoints && lhs.torusNodePub == rhs.torusNodePub && lhs.currentEpoch == rhs.currentEpoch && lhs.torusIndexes == rhs.torusIndexes && lhs.updated == rhs.updated
}
private var currentEpoch : String
private var torusNodeEndpoints : Array<String>
private var torusNodeSSSEndpoints : Array<String>
private var torusNodeRSSEndpoints : Array<String>
private var torusNodeTSSEndpoints : Array<String>
private var torusIndexes : Array<BigUInt>
private var torusNodePub : Array<TorusNodePubModel>
private var updated = false
public enum CodingKeys: String, CodingKey {
case currentEpoch = "currentEpoch"
case torusNodeEndpoints = "torusNodeEndpoints"
case torusNodeSSSEndpoints = "torusNodeSSSEndpoints"
case torusNodeRSSEndpoints = "torusNodeRSSEndpoints"
case torusNodeTSSEndpoints = "torusNodeTSSEndpoints"
case torusIndexes = "torusIndexes"
case torusNodePub = "torusNodePub"
case updated = "updated"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
currentEpoch = try container.decode(String.self, forKey: .currentEpoch)
torusNodeEndpoints = try container.decode([String].self, forKey: .torusNodeEndpoints)
torusNodeSSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeSSSEndpoints) ?? []
torusNodeRSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeRSSEndpoints) ?? []
torusNodeTSSEndpoints = try container.decodeIfPresent([String].self, forKey: .torusNodeTSSEndpoints) ?? []
// Decode torusIndexes as [Int]
let torusIndexesInt = try container.decode([Int].self, forKey: .torusIndexes)
// Convert [Int] to Array<BigUInt>
torusIndexes = torusIndexesInt.map { BigUInt($0) }
torusNodePub = try container.decode([TorusNodePubModel].self, forKey: .torusNodePub)
updated = try container.decodeIfPresent(Bool.self, forKey: .updated) ?? false
}
public init(_currentEpoch : String, _torusNodeEndpoints : Array<String>, _torusNodeSSSEndpoints : Array<String> = [], _torusNodeRSSEndpoints : Array<String> = [], _torusNodeTSSEndpoints : Array<String> = [], _torusIndexes : Array<BigUInt>, _torusNodePub : Array<TorusNodePubModel>, _updated : Bool = false) {
self.currentEpoch = _currentEpoch;
self.torusNodeSSSEndpoints = _torusNodeSSSEndpoints;
self.torusNodeRSSEndpoints = _torusNodeRSSEndpoints;
self.torusNodeTSSEndpoints = _torusNodeTSSEndpoints;
self.torusNodeEndpoints = _torusNodeEndpoints;
self.torusIndexes = _torusIndexes;
self.torusNodePub = _torusNodePub;
self.updated = _updated;
}
public func getTorusIndexes() -> Array<BigUInt> {
return self.torusIndexes;
}
public mutating func setTorusIndexes(torusIndexes : Array<BigUInt>){
self.torusIndexes = torusIndexes
}
public func getUpdated() -> Bool {
return updated
}
public mutating func setUpdated(updated : Bool){
self.updated = updated
}
public mutating func getCurrentEpoch() -> String{
return currentEpoch
}
public mutating func setCurrentEpoch( currentEpoch : String) {
self.currentEpoch = currentEpoch;
}
public func getTorusNodeEndpoints() -> Array<String> {
return torusNodeEndpoints
}
public mutating func setTorusNodeEndpoints(torusNodeEndpoints : Array<String>) {
self.torusNodeEndpoints = torusNodeEndpoints
}
public func getTorusNodePub() -> Array<TorusNodePubModel> {
return torusNodePub
}
public mutating func setTorusNodePub(torusNodePub : Array<TorusNodePubModel>) {
self.torusNodePub = torusNodePub
}
public func getTorusNodeSSSEndpoints() -> Array<String> {
return torusNodeSSSEndpoints
}
public mutating func setTorusNodeSSSEndpoints(torusNodeSSSEndpoints : Array<String>) {
self.torusNodeSSSEndpoints = torusNodeSSSEndpoints
}
public func getTorusNodeRSSEndpoints() -> Array<String> {
return torusNodeRSSEndpoints
}
public mutating func setTorusNodeRSSEndpoints(torusNodeRSSEndpoints : Array<String>) {
self.torusNodeRSSEndpoints = torusNodeRSSEndpoints
}
public func getTorusNodeTSSEndpoints() -> Array<String> {
return torusNodeTSSEndpoints
}
public mutating func setTorusNodeTSSEndpoints(torusNodeTSSEndpoints : Array<String>) {
self.torusNodeTSSEndpoints = torusNodeTSSEndpoints
}
public mutating func setNodeDetails(nodeDetails: AllNodeDetailsModel, updated: Bool) {
self.torusNodeEndpoints = nodeDetails.torusNodeEndpoints
self.torusNodeSSSEndpoints = nodeDetails.torusNodeSSSEndpoints
self.torusNodeRSSEndpoints = nodeDetails.torusNodeRSSEndpoints
self.torusNodeTSSEndpoints = nodeDetails.torusNodeTSSEndpoints
self.torusNodePub = nodeDetails.torusNodePub
self.torusIndexes = nodeDetails.torusIndexes
self.currentEpoch = nodeDetails.currentEpoch
self.updated = updated
}
}