add trusted flag to node model

node model fix
This commit is contained in:
sneurlax 2023-01-05 14:32:36 -06:00
parent 02ab644baf
commit 6391e474f0
2 changed files with 12 additions and 3 deletions

View file

@ -26,6 +26,8 @@ class NodeModel {
final bool isFailover; final bool isFailover;
// @HiveField(9) // @HiveField(9)
final bool isDown; final bool isDown;
// @HiveField(10)
final bool? trusted;
NodeModel({ NodeModel({
required this.host, required this.host,
@ -38,6 +40,7 @@ class NodeModel {
required this.isFailover, required this.isFailover,
required this.isDown, required this.isDown,
this.loginName, this.loginName,
this.trusted,
}); });
NodeModel copyWith({ NodeModel copyWith({
@ -50,6 +53,7 @@ class NodeModel {
String? coinName, String? coinName,
bool? isFailover, bool? isFailover,
bool? isDown, bool? isDown,
bool? trusted,
}) { }) {
return NodeModel( return NodeModel(
host: host ?? this.host, host: host ?? this.host,
@ -62,6 +66,7 @@ class NodeModel {
coinName: coinName ?? this.coinName, coinName: coinName ?? this.coinName,
isFailover: isFailover ?? this.isFailover, isFailover: isFailover ?? this.isFailover,
isDown: isDown ?? this.isDown, isDown: isDown ?? this.isDown,
trusted: trusted ?? this.trusted,
); );
} }
@ -82,6 +87,7 @@ class NodeModel {
map['coinName'] = coinName; map['coinName'] = coinName;
map['isFailover'] = isFailover; map['isFailover'] = isFailover;
map['isDown'] = isDown; map['isDown'] = isDown;
map['trusted'] = trusted;
return map; return map;
} }

View file

@ -26,14 +26,15 @@ class NodeModelAdapter extends TypeAdapter<NodeModel> {
loginName: fields[5] as String?, loginName: fields[5] as String?,
coinName: fields[7] as String, coinName: fields[7] as String,
isFailover: fields[8] as bool, isFailover: fields[8] as bool,
isDown: fields[8] as bool, isDown: fields[9] as bool,
trusted: fields[10] as bool?,
); );
} }
@override @override
void write(BinaryWriter writer, NodeModel obj) { void write(BinaryWriter writer, NodeModel obj) {
writer writer
..writeByte(10) ..writeByte(11)
..writeByte(0) ..writeByte(0)
..write(obj.id) ..write(obj.id)
..writeByte(1) ..writeByte(1)
@ -53,7 +54,9 @@ class NodeModelAdapter extends TypeAdapter<NodeModel> {
..writeByte(8) ..writeByte(8)
..write(obj.isFailover) ..write(obj.isFailover)
..writeByte(9) ..writeByte(9)
..write(obj.isDown); ..write(obj.isDown)
..writeByte(10)
..write(obj.trusted);
} }
@override @override