| 1232 | |
| 1233 | @functools.total_ordering |
| 1234 | class Balance(proto.Balance): |
| 1235 | __slots__ = "locked", |
| 1236 | |
| 1237 | def __init__(self, parent=None, locked=float(0.0)): |
| 1238 | super().__init__() |
| 1239 | if parent is None: |
| 1240 | parent = proto.Balance() |
| 1241 | super().copy(parent) |
| 1242 | self.locked = locked |
| 1243 | |
| 1244 | # Struct shallow copy |
| 1245 | def copy(self, other): |
| 1246 | super().copy(other) |
| 1247 | self.locked = other.locked |
| 1248 | return self |
| 1249 | |
| 1250 | # Struct deep clone |
| 1251 | def clone(self): |
| 1252 | # Serialize the struct to the FBE stream |
| 1253 | writer = BalanceModel(fbe.WriteBuffer()) |
| 1254 | writer.serialize(self) |
| 1255 | |
| 1256 | # Deserialize the struct from the FBE stream |
| 1257 | reader = BalanceModel(fbe.ReadBuffer()) |
| 1258 | reader.attach_buffer(writer.buffer) |
| 1259 | return reader.deserialize()[0] |
| 1260 | |
| 1261 | def __eq__(self, other): |
| 1262 | if not isinstance(self, other.__class__): |
| 1263 | return NotImplemented |
| 1264 | if not super().__eq__(other): |
| 1265 | return False |
| 1266 | return True |
| 1267 | |
| 1268 | def __lt__(self, other): |
| 1269 | if not isinstance(self, other.__class__): |
| 1270 | return NotImplemented |
| 1271 | if super().__lt__(other): |
| 1272 | return True |
| 1273 | if super().__eq__(other): |
| 1274 | return False |
| 1275 | return False |
| 1276 | |
| 1277 | @property |
| 1278 | def __key__(self): |
| 1279 | return super().__key__ + () |
| 1280 | |
| 1281 | def __hash__(self): |
| 1282 | return hash(self.__key__) |
| 1283 | |
| 1284 | def __format__(self, format_spec): |
| 1285 | return self.__str__() |
| 1286 | |
| 1287 | def __str__(self): |
| 1288 | sb = list() |
| 1289 | sb.append("Balance(") |
| 1290 | sb.append(proto.Balance.__str__(self)) |
| 1291 | sb.append(",locked=") |
no outgoing calls
no test coverage detected