Expose API to fetch checkpoints
This commit is contained in:
parent
b9726bf293
commit
337fe20b4f
|
@ -322,6 +322,8 @@ struct CResult_u8 update_excluded(uint8_t coin, uint32_t id, bool excluded);
|
||||||
|
|
||||||
struct CResult_u8 invert_excluded(uint8_t coin, uint32_t id);
|
struct CResult_u8 invert_excluded(uint8_t coin, uint32_t id);
|
||||||
|
|
||||||
|
struct CResult______u8 get_checkpoints(uint8_t coin);
|
||||||
|
|
||||||
bool has_cuda(void);
|
bool has_cuda(void);
|
||||||
|
|
||||||
bool has_metal(void);
|
bool has_metal(void);
|
||||||
|
|
|
@ -1019,6 +1019,15 @@ pub unsafe extern "C" fn invert_excluded(coin: u8, id: u32) -> CResult<u8> {
|
||||||
to_cresult(with_account(coin, res))
|
to_cresult(with_account(coin, res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn get_checkpoints(coin: u8) -> CResult<*const u8> {
|
||||||
|
let res = |connection: &Connection| {
|
||||||
|
let data = crate::db::read::get_checkpoints(connection)?;
|
||||||
|
Ok(data)
|
||||||
|
};
|
||||||
|
to_cresult_bytes(with_account(coin, res))
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn has_cuda() -> bool {
|
pub unsafe extern "C" fn has_cuda() -> bool {
|
||||||
crate::gpu::has_cuda()
|
crate::gpu::has_cuda()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -603,64 +603,28 @@ pub fn invert_excluded(connection: &Connection, id: u32) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
pub fn get_checkpoints(connection: &Connection) -> Result<Vec<u8>> {
|
||||||
,
|
let mut builder = flatbuffers::FlatBufferBuilder::new();
|
||||||
|
let mut stmt = connection.prepare("SELECT height, timestamp FROM blocks ORDER by height")?;
|
||||||
|
let rows = stmt.query_map([], |row| {
|
||||||
|
let height: u32 = row.get(0)?;
|
||||||
|
let timestamp: u32 = row.get(1)?;
|
||||||
|
|
||||||
"SELECT timestamp, value FROM transactions WHERE account = ?1 AND timestamp >= ?2 ORDER BY timestamp DESC",
|
let checkpoint = Checkpoint::create(&mut builder, &CheckpointArgs { height, timestamp });
|
||||||
|
Ok(checkpoint)
|
||||||
final List<Map> res = await db.rawQuery(
|
})?;
|
||||||
"SELECT SUM(value) as v, t.address, c.name FROM transactions t LEFT JOIN contacts c ON t.address = c.address "
|
let mut checkpoints = vec![];
|
||||||
"WHERE account = ?1 AND timestamp >= ?2 AND value < 0 GROUP BY t.address ORDER BY v ASC LIMIT 5",
|
for r in rows {
|
||||||
[accountId, range.start ~/ 1000]);
|
checkpoints.push(r?);
|
||||||
final spendings = res.map((row) {
|
|
||||||
final address = row['address'] ?? "";
|
|
||||||
final value = -row['v'] / ZECUNIT;
|
|
||||||
final contact = row['name'];
|
|
||||||
return Spending(address, value, contact);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
|
|
||||||
"SELECT timestamp, price FROM historical_prices WHERE timestamp >= ?2 AND currency = ?1",
|
|
||||||
|
|
||||||
|
|
||||||
final List<Map> res1 = await db.rawQuery(
|
|
||||||
"SELECT timestamp, value FROM transactions WHERE timestamp >= ?2 AND account = ?1",
|
|
||||||
[accountId, range.start ~/ 1000]);
|
|
||||||
|
|
||||||
|
|
||||||
List<Map> res = await db.rawQuery(
|
|
||||||
"SELECT id, name, address FROM contacts WHERE address <> '' ORDER BY name");
|
|
||||||
for (var c in res) {
|
|
||||||
final contact = Contact(c['id'], c['name'], c['address']);
|
|
||||||
contacts.add(contact);
|
|
||||||
}
|
}
|
||||||
|
let checkpoints = builder.create_vector(&checkpoints);
|
||||||
|
let checkpoints = CheckpointVec::create(
|
||||||
Future<int?> getPrevMessage(String subject, int height, int account) async {
|
&mut builder,
|
||||||
final id = await Sqflite.firstIntValue(await db.rawQuery(
|
&CheckpointVecArgs {
|
||||||
"SELECT MAX(id) FROM messages WHERE subject = ?1 AND height < ?2 and account = ?3",
|
values: Some(checkpoints),
|
||||||
[subject, height, account]));
|
},
|
||||||
return id;
|
);
|
||||||
|
builder.finish(checkpoints, None);
|
||||||
|
let data = builder.finished_data().to_vec();
|
||||||
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int?> getNextMessage(String subject, int height, int account) async {
|
|
||||||
final id = await Sqflite.firstIntValue(await db.rawQuery(
|
|
||||||
"SELECT MIN(id) FROM messages WHERE subject = ?1 AND height > ?2 and account = ?3",
|
|
||||||
[subject, height, account]));
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final id = row['id'];
|
|
||||||
final txId = row['id_tx'] ?? 0;
|
|
||||||
final timestamp = DateTime.fromMillisecondsSinceEpoch(row['timestamp'] * 1000);
|
|
||||||
final height = row['height'];
|
|
||||||
final sender = row['sender'];
|
|
||||||
final from = row['scontact'] ?? row['saccount'] ?? sender;
|
|
||||||
final recipient = row['recipient'];
|
|
||||||
final to = row['rcontact'] ?? row['raccount'] ?? recipient;
|
|
||||||
final subject = row['subject'];
|
|
||||||
final body = row['body'];
|
|
||||||
final read = row['read'] == 1;
|
|
||||||
final incoming = row['incoming'] == 1;
|
|
||||||
*/
|
|
||||||
|
|
Loading…
Reference in New Issue