update utxo

This commit is contained in:
julian 2023-03-08 08:57:17 -06:00
parent 6d22304d7b
commit cf6fb46c5c
2 changed files with 86 additions and 10 deletions

View file

@ -19,6 +19,7 @@ class UTXO {
required this.blockHeight, required this.blockHeight,
required this.blockTime, required this.blockTime,
this.address, this.address,
this.used,
this.otherData, this.otherData,
}); });
@ -54,6 +55,8 @@ class UTXO {
late final String? address; late final String? address;
late final bool? used;
late final String? otherData; late final String? otherData;
int getConfirmations(int currentChainHeight) { int getConfirmations(int currentChainHeight) {
@ -81,6 +84,7 @@ class UTXO {
int? blockHeight, int? blockHeight,
int? blockTime, int? blockTime,
String? address, String? address,
bool? used,
String? otherData, String? otherData,
}) => }) =>
UTXO( UTXO(
@ -96,6 +100,7 @@ class UTXO {
blockHeight: blockHeight ?? this.blockHeight, blockHeight: blockHeight ?? this.blockHeight,
blockTime: blockTime ?? this.blockTime, blockTime: blockTime ?? this.blockTime,
address: address ?? this.address, address: address ?? this.address,
used: used ?? this.used,
otherData: otherData ?? this.otherData, otherData: otherData ?? this.otherData,
)..id = id ?? this.id; )..id = id ?? this.id;
@ -114,6 +119,7 @@ class UTXO {
"blockHeight: $blockHeight, " "blockHeight: $blockHeight, "
"blockTime: $blockTime, " "blockTime: $blockTime, "
"address: $address, " "address: $address, "
"used: $used, "
"otherData: $otherData, " "otherData: $otherData, "
"}"; "}";

View file

@ -67,18 +67,23 @@ const UTXOSchema = CollectionSchema(
name: r'txid', name: r'txid',
type: IsarType.string, type: IsarType.string,
), ),
r'value': PropertySchema( r'used': PropertySchema(
id: 10, id: 10,
name: r'used',
type: IsarType.bool,
),
r'value': PropertySchema(
id: 11,
name: r'value', name: r'value',
type: IsarType.long, type: IsarType.long,
), ),
r'vout': PropertySchema( r'vout': PropertySchema(
id: 11, id: 12,
name: r'vout', name: r'vout',
type: IsarType.long, type: IsarType.long,
), ),
r'walletId': PropertySchema( r'walletId': PropertySchema(
id: 12, id: 13,
name: r'walletId', name: r'walletId',
type: IsarType.string, type: IsarType.string,
) )
@ -199,9 +204,10 @@ void _uTXOSerialize(
writer.writeString(offsets[7], object.name); writer.writeString(offsets[7], object.name);
writer.writeString(offsets[8], object.otherData); writer.writeString(offsets[8], object.otherData);
writer.writeString(offsets[9], object.txid); writer.writeString(offsets[9], object.txid);
writer.writeLong(offsets[10], object.value); writer.writeBool(offsets[10], object.used);
writer.writeLong(offsets[11], object.vout); writer.writeLong(offsets[11], object.value);
writer.writeString(offsets[12], object.walletId); writer.writeLong(offsets[12], object.vout);
writer.writeString(offsets[13], object.walletId);
} }
UTXO _uTXODeserialize( UTXO _uTXODeserialize(
@ -221,9 +227,10 @@ UTXO _uTXODeserialize(
name: reader.readString(offsets[7]), name: reader.readString(offsets[7]),
otherData: reader.readStringOrNull(offsets[8]), otherData: reader.readStringOrNull(offsets[8]),
txid: reader.readString(offsets[9]), txid: reader.readString(offsets[9]),
value: reader.readLong(offsets[10]), used: reader.readBoolOrNull(offsets[10]),
vout: reader.readLong(offsets[11]), value: reader.readLong(offsets[11]),
walletId: reader.readString(offsets[12]), vout: reader.readLong(offsets[12]),
walletId: reader.readString(offsets[13]),
); );
object.id = id; object.id = id;
return object; return object;
@ -257,10 +264,12 @@ P _uTXODeserializeProp<P>(
case 9: case 9:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
case 10: case 10:
return (reader.readLong(offset)) as P; return (reader.readBoolOrNull(offset)) as P;
case 11: case 11:
return (reader.readLong(offset)) as P; return (reader.readLong(offset)) as P;
case 12: case 12:
return (reader.readLong(offset)) as P;
case 13:
return (reader.readString(offset)) as P; return (reader.readString(offset)) as P;
default: default:
throw IsarError('Unknown property with id $propertyId'); throw IsarError('Unknown property with id $propertyId');
@ -1773,6 +1782,31 @@ extension UTXOQueryFilter on QueryBuilder<UTXO, UTXO, QFilterCondition> {
}); });
} }
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> usedIsNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNull(
property: r'used',
));
});
}
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> usedIsNotNull() {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(const FilterCondition.isNotNull(
property: r'used',
));
});
}
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> usedEqualTo(bool? value) {
return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo(
property: r'used',
value: value,
));
});
}
QueryBuilder<UTXO, UTXO, QAfterFilterCondition> valueEqualTo(int value) { QueryBuilder<UTXO, UTXO, QAfterFilterCondition> valueEqualTo(int value) {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addFilterCondition(FilterCondition.equalTo( return query.addFilterCondition(FilterCondition.equalTo(
@ -2132,6 +2166,18 @@ extension UTXOQuerySortBy on QueryBuilder<UTXO, UTXO, QSortBy> {
}); });
} }
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByUsed() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'used', Sort.asc);
});
}
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByUsedDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'used', Sort.desc);
});
}
QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByValue() { QueryBuilder<UTXO, UTXO, QAfterSortBy> sortByValue() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'value', Sort.asc); return query.addSortBy(r'value', Sort.asc);
@ -2302,6 +2348,18 @@ extension UTXOQuerySortThenBy on QueryBuilder<UTXO, UTXO, QSortThenBy> {
}); });
} }
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByUsed() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'used', Sort.asc);
});
}
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByUsedDesc() {
return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'used', Sort.desc);
});
}
QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByValue() { QueryBuilder<UTXO, UTXO, QAfterSortBy> thenByValue() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addSortBy(r'value', Sort.asc); return query.addSortBy(r'value', Sort.asc);
@ -2407,6 +2465,12 @@ extension UTXOQueryWhereDistinct on QueryBuilder<UTXO, UTXO, QDistinct> {
}); });
} }
QueryBuilder<UTXO, UTXO, QDistinct> distinctByUsed() {
return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'used');
});
}
QueryBuilder<UTXO, UTXO, QDistinct> distinctByValue() { QueryBuilder<UTXO, UTXO, QDistinct> distinctByValue() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addDistinctBy(r'value'); return query.addDistinctBy(r'value');
@ -2494,6 +2558,12 @@ extension UTXOQueryProperty on QueryBuilder<UTXO, UTXO, QQueryProperty> {
}); });
} }
QueryBuilder<UTXO, bool?, QQueryOperations> usedProperty() {
return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'used');
});
}
QueryBuilder<UTXO, int, QQueryOperations> valueProperty() { QueryBuilder<UTXO, int, QQueryOperations> valueProperty() {
return QueryBuilder.apply(this, (query) { return QueryBuilder.apply(this, (query) {
return query.addPropertyName(r'value'); return query.addPropertyName(r'value');