diff --git a/lib/models/isar/models/address/address.dart b/lib/models/isar/models/address/address.dart index 054e620b3..367a3fab4 100644 --- a/lib/models/isar/models/address/address.dart +++ b/lib/models/isar/models/address/address.dart @@ -8,7 +8,7 @@ class AddressException extends SWException { AddressException(super.message); } -@collection +@Collection(accessor: "addresses") class Address extends CryptoCurrencyAddress { Id id = Isar.autoIncrement; diff --git a/lib/models/isar/models/address/address.g.dart b/lib/models/isar/models/address/address.g.dart index 349c7a852..44d5c1d71 100644 --- a/lib/models/isar/models/address/address.g.dart +++ b/lib/models/isar/models/address/address.g.dart @@ -10,7 +10,7 @@ part of 'address.dart'; // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters extension GetAddressCollection on Isar { - IsarCollection
get address => this.collection(); + IsarCollection
get addresses => this.collection(); } const AddressSchema = CollectionSchema( diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index c59c19b06..9a6849146 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -253,7 +253,7 @@ const _TransactionsubTypeValueEnumMap = { const _TransactiontypeEnumValueMap = { 'outgoing': 0, 'incoming': 1, - 'sendToSelf': 2, + 'sentToSelf': 2, 'unknown': 3, 'anonymize': 4, }; diff --git a/lib/models/isar/models/blockchain_data/utxo.dart b/lib/models/isar/models/blockchain_data/utxo.dart index 47701f4db..eda4c06ff 100644 --- a/lib/models/isar/models/blockchain_data/utxo.dart +++ b/lib/models/isar/models/blockchain_data/utxo.dart @@ -4,37 +4,35 @@ import 'package:isar/isar.dart'; part 'utxo.g.dart'; -@Collection() +@Collection(accessor: "utxos") class UTXO { Id id = Isar.autoIncrement; + @Index(unique: true, replace: true) late String txid; late int vout; - late Status status; - late int value; - late String txName; + late String name; - late bool blocked; + @Index() + late bool isBlocked; late String? blockedReason; late bool isCoinbase; -} -@Embedded() -class Status { - late String blockHash; + late String? blockHash; - late int blockHeight; + late int? blockHeight; - late int blockTime; + late int? blockTime; int getConfirmations(int currentChainHeight) { - return max(0, currentChainHeight - blockHeight); + if (blockHeight == null) return 0; + return max(0, currentChainHeight - blockHeight!); } bool isConfirmed(int currentChainHeight, int minimumConfirms) { diff --git a/lib/models/isar/models/blockchain_data/utxo.g.dart b/lib/models/isar/models/blockchain_data/utxo.g.dart index b86822039..9c0772968 100644 --- a/lib/models/isar/models/blockchain_data/utxo.g.dart +++ b/lib/models/isar/models/blockchain_data/utxo.g.dart @@ -10,51 +10,60 @@ part of 'utxo.dart'; // ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters extension GetUTXOCollection on Isar { - IsarCollection get uTXOs => this.collection(); + IsarCollection get utxos => this.collection(); } const UTXOSchema = CollectionSchema( name: r'UTXO', id: 5934032492047519621, properties: { - r'blocked': PropertySchema( + r'blockHash': PropertySchema( id: 0, - name: r'blocked', - type: IsarType.bool, + name: r'blockHash', + type: IsarType.string, + ), + r'blockHeight': PropertySchema( + id: 1, + name: r'blockHeight', + type: IsarType.long, + ), + r'blockTime': PropertySchema( + id: 2, + name: r'blockTime', + type: IsarType.long, ), r'blockedReason': PropertySchema( - id: 1, + id: 3, name: r'blockedReason', type: IsarType.string, ), + r'isBlocked': PropertySchema( + id: 4, + name: r'isBlocked', + type: IsarType.bool, + ), r'isCoinbase': PropertySchema( - id: 2, + id: 5, name: r'isCoinbase', type: IsarType.bool, ), - r'status': PropertySchema( - id: 3, - name: r'status', - type: IsarType.object, - target: r'Status', - ), - r'txName': PropertySchema( - id: 4, - name: r'txName', + r'name': PropertySchema( + id: 6, + name: r'name', type: IsarType.string, ), r'txid': PropertySchema( - id: 5, + id: 7, name: r'txid', type: IsarType.string, ), r'value': PropertySchema( - id: 6, + id: 8, name: r'value', type: IsarType.long, ), r'vout': PropertySchema( - id: 7, + id: 9, name: r'vout', type: IsarType.long, ) @@ -64,9 +73,36 @@ const UTXOSchema = CollectionSchema( deserialize: _uTXODeserialize, deserializeProp: _uTXODeserializeProp, idName: r'id', - indexes: {}, + indexes: { + r'txid': IndexSchema( + id: 7339874292043634331, + name: r'txid', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'txid', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ), + r'isBlocked': IndexSchema( + id: 4270553749242334751, + name: r'isBlocked', + unique: false, + replace: false, + properties: [ + IndexPropertySchema( + name: r'isBlocked', + type: IndexType.value, + caseSensitive: false, + ) + ], + ) + }, links: {}, - embeddedSchemas: {r'Status': StatusSchema}, + embeddedSchemas: {}, getId: _uTXOGetId, getLinks: _uTXOGetLinks, attach: _uTXOAttach, @@ -79,15 +115,19 @@ int _uTXOEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + { + final value = object.blockHash; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } { final value = object.blockedReason; if (value != null) { bytesCount += 3 + value.length * 3; } } - bytesCount += 3 + - StatusSchema.estimateSize(object.status, allOffsets[Status]!, allOffsets); - bytesCount += 3 + object.txName.length * 3; + bytesCount += 3 + object.name.length * 3; bytesCount += 3 + object.txid.length * 3; return bytesCount; } @@ -98,19 +138,16 @@ void _uTXOSerialize( List offsets, Map> allOffsets, ) { - writer.writeBool(offsets[0], object.blocked); - writer.writeString(offsets[1], object.blockedReason); - writer.writeBool(offsets[2], object.isCoinbase); - writer.writeObject( - offsets[3], - allOffsets, - StatusSchema.serialize, - object.status, - ); - writer.writeString(offsets[4], object.txName); - writer.writeString(offsets[5], object.txid); - writer.writeLong(offsets[6], object.value); - writer.writeLong(offsets[7], object.vout); + writer.writeString(offsets[0], object.blockHash); + writer.writeLong(offsets[1], object.blockHeight); + writer.writeLong(offsets[2], object.blockTime); + writer.writeString(offsets[3], object.blockedReason); + writer.writeBool(offsets[4], object.isBlocked); + writer.writeBool(offsets[5], object.isCoinbase); + writer.writeString(offsets[6], object.name); + writer.writeString(offsets[7], object.txid); + writer.writeLong(offsets[8], object.value); + writer.writeLong(offsets[9], object.vout); } UTXO _uTXODeserialize( @@ -120,20 +157,17 @@ UTXO _uTXODeserialize( Map> allOffsets, ) { final object = UTXO(); - object.blocked = reader.readBool(offsets[0]); - object.blockedReason = reader.readStringOrNull(offsets[1]); + object.blockHash = reader.readStringOrNull(offsets[0]); + object.blockHeight = reader.readLongOrNull(offsets[1]); + object.blockTime = reader.readLongOrNull(offsets[2]); + object.blockedReason = reader.readStringOrNull(offsets[3]); object.id = id; - object.isCoinbase = reader.readBool(offsets[2]); - object.status = reader.readObjectOrNull( - offsets[3], - StatusSchema.deserialize, - allOffsets, - ) ?? - Status(); - object.txName = reader.readString(offsets[4]); - object.txid = reader.readString(offsets[5]); - object.value = reader.readLong(offsets[6]); - object.vout = reader.readLong(offsets[7]); + object.isBlocked = reader.readBool(offsets[4]); + object.isCoinbase = reader.readBool(offsets[5]); + object.name = reader.readString(offsets[6]); + object.txid = reader.readString(offsets[7]); + object.value = reader.readLong(offsets[8]); + object.vout = reader.readLong(offsets[9]); return object; } @@ -145,25 +179,24 @@ P _uTXODeserializeProp

( ) { switch (propertyId) { case 0: - return (reader.readBool(offset)) as P; - case 1: return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readLongOrNull(offset)) as P; case 2: - return (reader.readBool(offset)) as P; + return (reader.readLongOrNull(offset)) as P; case 3: - return (reader.readObjectOrNull( - offset, - StatusSchema.deserialize, - allOffsets, - ) ?? - Status()) as P; + return (reader.readStringOrNull(offset)) as P; case 4: - return (reader.readString(offset)) as P; + return (reader.readBool(offset)) as P; case 5: - return (reader.readString(offset)) as P; + return (reader.readBool(offset)) as P; case 6: - return (reader.readLong(offset)) as P; + return (reader.readString(offset)) as P; case 7: + return (reader.readString(offset)) as P; + case 8: + return (reader.readLong(offset)) as P; + case 9: return (reader.readLong(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -182,12 +215,74 @@ void _uTXOAttach(IsarCollection col, Id id, UTXO object) { object.id = id; } +extension UTXOByIndex on IsarCollection { + Future getByTxid(String txid) { + return getByIndex(r'txid', [txid]); + } + + UTXO? getByTxidSync(String txid) { + return getByIndexSync(r'txid', [txid]); + } + + Future deleteByTxid(String txid) { + return deleteByIndex(r'txid', [txid]); + } + + bool deleteByTxidSync(String txid) { + return deleteByIndexSync(r'txid', [txid]); + } + + Future> getAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndex(r'txid', values); + } + + List getAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'txid', values); + } + + Future deleteAllByTxid(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'txid', values); + } + + int deleteAllByTxidSync(List txidValues) { + final values = txidValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'txid', values); + } + + Future putByTxid(UTXO object) { + return putByIndex(r'txid', object); + } + + Id putByTxidSync(UTXO object, {bool saveLinks = true}) { + return putByIndexSync(r'txid', object, saveLinks: saveLinks); + } + + Future> putAllByTxid(List objects) { + return putAllByIndex(r'txid', objects); + } + + List putAllByTxidSync(List objects, {bool saveLinks = true}) { + return putAllByIndexSync(r'txid', objects, saveLinks: saveLinks); + } +} + extension UTXOQueryWhereSort on QueryBuilder { QueryBuilder anyId() { return QueryBuilder.apply(this, (query) { return query.addWhereClause(const IdWhereClause.any()); }); } + + QueryBuilder anyIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + const IndexWhereClause.any(indexName: r'isBlocked'), + ); + }); + } } extension UTXOQueryWhere on QueryBuilder { @@ -255,14 +350,375 @@ extension UTXOQueryWhere on QueryBuilder { )); }); } + + QueryBuilder txidEqualTo(String txid) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'txid', + value: [txid], + )); + }); + } + + QueryBuilder txidNotEqualTo(String txid) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [txid], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'txid', + lower: [], + upper: [txid], + includeUpper: false, + )); + } + }); + } + + QueryBuilder isBlockedEqualTo(bool isBlocked) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'isBlocked', + value: [isBlocked], + )); + }); + } + + QueryBuilder isBlockedNotEqualTo( + bool isBlocked) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [], + upper: [isBlocked], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [isBlocked], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [isBlocked], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'isBlocked', + lower: [], + upper: [isBlocked], + includeUpper: false, + )); + } + }); + } } extension UTXOQueryFilter on QueryBuilder { - QueryBuilder blockedEqualTo(bool value) { + QueryBuilder blockHashIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockHash', + )); + }); + } + + QueryBuilder blockHashIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockHash', + )); + }); + } + + QueryBuilder blockHashEqualTo( + String? value, { + bool caseSensitive = true, + }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'blocked', + property: r'blockHash', value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHash', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'blockHash', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'blockHash', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder blockHashIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHashIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'blockHash', + value: '', + )); + }); + } + + QueryBuilder blockHeightIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockHeight', + )); + }); + } + + QueryBuilder blockHeightIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockHeight', + )); + }); + } + + QueryBuilder blockHeightEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockHeight', + value: value, + )); + }); + } + + QueryBuilder blockHeightBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockHeight', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder blockTimeIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'blockTime', + )); + }); + } + + QueryBuilder blockTimeIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'blockTime', + )); + }); + } + + QueryBuilder blockTimeEqualTo(int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'blockTime', + value: value, + )); + }); + } + + QueryBuilder blockTimeBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'blockTime', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, )); }); } @@ -465,6 +921,15 @@ extension UTXOQueryFilter on QueryBuilder { }); } + QueryBuilder isBlockedEqualTo(bool value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'isBlocked', + value: value, + )); + }); + } + QueryBuilder isCoinbaseEqualTo( bool value) { return QueryBuilder.apply(this, (query) { @@ -475,20 +940,20 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder txNameEqualTo( + QueryBuilder nameEqualTo( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameGreaterThan( + QueryBuilder nameGreaterThan( String value, { bool include = false, bool caseSensitive = true, @@ -496,14 +961,14 @@ extension UTXOQueryFilter on QueryBuilder { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( include: include, - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameLessThan( + QueryBuilder nameLessThan( String value, { bool include = false, bool caseSensitive = true, @@ -511,14 +976,14 @@ extension UTXOQueryFilter on QueryBuilder { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.lessThan( include: include, - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameBetween( + QueryBuilder nameBetween( String lower, String upper, { bool includeLower = true, @@ -527,7 +992,7 @@ extension UTXOQueryFilter on QueryBuilder { }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.between( - property: r'txName', + property: r'name', lower: lower, includeLower: includeLower, upper: upper, @@ -537,67 +1002,67 @@ extension UTXOQueryFilter on QueryBuilder { }); } - QueryBuilder txNameStartsWith( + QueryBuilder nameStartsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.startsWith( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameEndsWith( + QueryBuilder nameEndsWith( String value, { bool caseSensitive = true, }) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.endsWith( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameContains(String value, + QueryBuilder nameContains(String value, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.contains( - property: r'txName', + property: r'name', value: value, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameMatches(String pattern, + QueryBuilder nameMatches(String pattern, {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.matches( - property: r'txName', + property: r'name', wildcard: pattern, caseSensitive: caseSensitive, )); }); } - QueryBuilder txNameIsEmpty() { + QueryBuilder nameIsEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.equalTo( - property: r'txName', + property: r'name', value: '', )); }); } - QueryBuilder txNameIsNotEmpty() { + QueryBuilder nameIsNotEmpty() { return QueryBuilder.apply(this, (query) { return query.addFilterCondition(FilterCondition.greaterThan( - property: r'txName', + property: r'name', value: '', )); }); @@ -836,27 +1301,44 @@ extension UTXOQueryFilter on QueryBuilder { } } -extension UTXOQueryObject on QueryBuilder { - QueryBuilder status( - FilterQuery q) { - return QueryBuilder.apply(this, (query) { - return query.object(q, r'status'); - }); - } -} +extension UTXOQueryObject on QueryBuilder {} extension UTXOQueryLinks on QueryBuilder {} extension UTXOQuerySortBy on QueryBuilder { - QueryBuilder sortByBlocked() { + QueryBuilder sortByBlockHash() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.asc); + return query.addSortBy(r'blockHash', Sort.asc); }); } - QueryBuilder sortByBlockedDesc() { + QueryBuilder sortByBlockHashDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.desc); + return query.addSortBy(r'blockHash', Sort.desc); + }); + } + + QueryBuilder sortByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.asc); + }); + } + + QueryBuilder sortByBlockHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.desc); + }); + } + + QueryBuilder sortByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.asc); + }); + } + + QueryBuilder sortByBlockTimeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.desc); }); } @@ -872,6 +1354,18 @@ extension UTXOQuerySortBy on QueryBuilder { }); } + QueryBuilder sortByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.asc); + }); + } + + QueryBuilder sortByIsBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.desc); + }); + } + QueryBuilder sortByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'isCoinbase', Sort.asc); @@ -884,15 +1378,15 @@ extension UTXOQuerySortBy on QueryBuilder { }); } - QueryBuilder sortByTxName() { + QueryBuilder sortByName() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.asc); + return query.addSortBy(r'name', Sort.asc); }); } - QueryBuilder sortByTxNameDesc() { + QueryBuilder sortByNameDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.desc); + return query.addSortBy(r'name', Sort.desc); }); } @@ -934,15 +1428,39 @@ extension UTXOQuerySortBy on QueryBuilder { } extension UTXOQuerySortThenBy on QueryBuilder { - QueryBuilder thenByBlocked() { + QueryBuilder thenByBlockHash() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.asc); + return query.addSortBy(r'blockHash', Sort.asc); }); } - QueryBuilder thenByBlockedDesc() { + QueryBuilder thenByBlockHashDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'blocked', Sort.desc); + return query.addSortBy(r'blockHash', Sort.desc); + }); + } + + QueryBuilder thenByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.asc); + }); + } + + QueryBuilder thenByBlockHeightDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockHeight', Sort.desc); + }); + } + + QueryBuilder thenByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.asc); + }); + } + + QueryBuilder thenByBlockTimeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'blockTime', Sort.desc); }); } @@ -970,6 +1488,18 @@ extension UTXOQuerySortThenBy on QueryBuilder { }); } + QueryBuilder thenByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.asc); + }); + } + + QueryBuilder thenByIsBlockedDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'isBlocked', Sort.desc); + }); + } + QueryBuilder thenByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'isCoinbase', Sort.asc); @@ -982,15 +1512,15 @@ extension UTXOQuerySortThenBy on QueryBuilder { }); } - QueryBuilder thenByTxName() { + QueryBuilder thenByName() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.asc); + return query.addSortBy(r'name', Sort.asc); }); } - QueryBuilder thenByTxNameDesc() { + QueryBuilder thenByNameDesc() { return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txName', Sort.desc); + return query.addSortBy(r'name', Sort.desc); }); } @@ -1032,9 +1562,22 @@ extension UTXOQuerySortThenBy on QueryBuilder { } extension UTXOQueryWhereDistinct on QueryBuilder { - QueryBuilder distinctByBlocked() { + QueryBuilder distinctByBlockHash( + {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'blocked'); + return query.addDistinctBy(r'blockHash', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByBlockHeight() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'blockHeight'); + }); + } + + QueryBuilder distinctByBlockTime() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'blockTime'); }); } @@ -1046,16 +1589,22 @@ extension UTXOQueryWhereDistinct on QueryBuilder { }); } + QueryBuilder distinctByIsBlocked() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'isBlocked'); + }); + } + QueryBuilder distinctByIsCoinbase() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'isCoinbase'); }); } - QueryBuilder distinctByTxName( + QueryBuilder distinctByName( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'txName', caseSensitive: caseSensitive); + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); }); } @@ -1086,9 +1635,21 @@ extension UTXOQueryProperty on QueryBuilder { }); } - QueryBuilder blockedProperty() { + QueryBuilder blockHashProperty() { return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'blocked'); + return query.addPropertyName(r'blockHash'); + }); + } + + QueryBuilder blockHeightProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'blockHeight'); + }); + } + + QueryBuilder blockTimeProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'blockTime'); }); } @@ -1098,21 +1659,21 @@ extension UTXOQueryProperty on QueryBuilder { }); } + QueryBuilder isBlockedProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'isBlocked'); + }); + } + QueryBuilder isCoinbaseProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'isCoinbase'); }); } - QueryBuilder statusProperty() { + QueryBuilder nameProperty() { return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'status'); - }); - } - - QueryBuilder txNameProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'txName'); + return query.addPropertyName(r'name'); }); } @@ -1134,328 +1695,3 @@ extension UTXOQueryProperty on QueryBuilder { }); } } - -// ************************************************************************** -// IsarEmbeddedGenerator -// ************************************************************************** - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters - -const StatusSchema = Schema( - name: r'Status', - id: -8158262482337811485, - properties: { - r'blockHash': PropertySchema( - id: 0, - name: r'blockHash', - type: IsarType.string, - ), - r'blockHeight': PropertySchema( - id: 1, - name: r'blockHeight', - type: IsarType.long, - ), - r'blockTime': PropertySchema( - id: 2, - name: r'blockTime', - type: IsarType.long, - ) - }, - estimateSize: _statusEstimateSize, - serialize: _statusSerialize, - deserialize: _statusDeserialize, - deserializeProp: _statusDeserializeProp, -); - -int _statusEstimateSize( - Status object, - List offsets, - Map> allOffsets, -) { - var bytesCount = offsets.last; - bytesCount += 3 + object.blockHash.length * 3; - return bytesCount; -} - -void _statusSerialize( - Status object, - IsarWriter writer, - List offsets, - Map> allOffsets, -) { - writer.writeString(offsets[0], object.blockHash); - writer.writeLong(offsets[1], object.blockHeight); - writer.writeLong(offsets[2], object.blockTime); -} - -Status _statusDeserialize( - Id id, - IsarReader reader, - List offsets, - Map> allOffsets, -) { - final object = Status(); - object.blockHash = reader.readString(offsets[0]); - object.blockHeight = reader.readLong(offsets[1]); - object.blockTime = reader.readLong(offsets[2]); - return object; -} - -P _statusDeserializeProp

( - IsarReader reader, - int propertyId, - int offset, - Map> allOffsets, -) { - switch (propertyId) { - case 0: - return (reader.readString(offset)) as P; - case 1: - return (reader.readLong(offset)) as P; - case 2: - return (reader.readLong(offset)) as P; - default: - throw IsarError('Unknown property with id $propertyId'); - } -} - -extension StatusQueryFilter on QueryBuilder { - QueryBuilder blockHashEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockHash', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'blockHash', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'blockHash', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder blockHashIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHash', - value: '', - )); - }); - } - - QueryBuilder blockHashIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'blockHash', - value: '', - )); - }); - } - - QueryBuilder blockHeightEqualTo( - int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockHeight', - value: value, - )); - }); - } - - QueryBuilder blockHeightBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockHeight', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder blockTimeEqualTo( - int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'blockTime', - value: value, - )); - }); - } - - QueryBuilder blockTimeBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'blockTime', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } -} - -extension StatusQueryObject on QueryBuilder {}