35 lines
1.0 KiB
Rust
35 lines
1.0 KiB
Rust
|
|
use bft_crdt_derive::add_crdt_fields;
|
||
|
|
use bft_json_crdt::{
|
||
|
|
json_crdt::{CrdtNode, IntoCrdtNode},
|
||
|
|
list_crdt::ListCrdt,
|
||
|
|
};
|
||
|
|
use serde::{Deserialize, Serialize};
|
||
|
|
|
||
|
|
#[add_crdt_fields]
|
||
|
|
#[derive(Clone, CrdtNode, Serialize, Deserialize)]
|
||
|
|
pub(crate) struct TransactionList {
|
||
|
|
pub(crate) list: ListCrdt<Transaction>,
|
||
|
|
}
|
||
|
|
|
||
|
|
/// A fake Transaction struct we can use as a simulated payload
|
||
|
|
#[add_crdt_fields]
|
||
|
|
#[derive(Clone, CrdtNode, Serialize, Deserialize)]
|
||
|
|
pub(crate) struct Transaction {
|
||
|
|
from: String,
|
||
|
|
to: String,
|
||
|
|
amount: f64,
|
||
|
|
}
|
||
|
|
|
||
|
|
// impl TransactionList {
|
||
|
|
// fn create(&mut self, keys: &Ed25519KeyPair) -> bft_json_crdt::json_crdt::SignedOp {
|
||
|
|
// // generate a placeholder transaction
|
||
|
|
// let transaction = _fake_transaction(keys.public().to_string());
|
||
|
|
|
||
|
|
// // next job is to keep adding to this guy
|
||
|
|
// let last: &Op<Transaction>;
|
||
|
|
// last = self.list.ops.last().expect("couldn't find last op");
|
||
|
|
// let signed_op = self.list.insert(last.id, transaction.clone()).sign(&keys);
|
||
|
|
// signed_op
|
||
|
|
// }
|
||
|
|
// }
|