Giving nodes the ability to send transactions in a more controlled fashion

This commit is contained in:
Dave Hrycyszyn
2024-06-06 19:50:24 +01:00
parent 3f4b4324e5
commit 95e3127903
2 changed files with 15 additions and 29 deletions

View File

@@ -35,14 +35,12 @@ pub(crate) fn new(side_dir: PathBuf) -> (BaseCrdt<CrdtList>, Ed25519KeyPair) {
(bft_crdt, keys)
}
pub(crate) async fn send(
count: u32,
pub(crate) fn send(
bft_crdt: &mut BaseCrdt<CrdtList>,
// ws: &mut WebSocket,
keys: &Ed25519KeyPair,
) {
) -> bft_json_crdt::json_crdt::SignedOp {
// generate a placeholder transaction
let transaction = generate_transaction(count, keys.public().to_string());
let transaction = generate_transaction(keys.public().to_string());
// next job is to keep adding to this guy
let next = bft_crdt.doc.list.ops.len();
@@ -51,16 +49,13 @@ pub(crate) async fn send(
.list
.insert_idx(next - 1, transaction.clone())
.sign(&keys);
// Ok(ws
// .send_text(serde_json::to_string(&signed_op).unwrap())
// .await?)
signed_op
}
fn generate_transaction(count: u32, pubkey: String) -> Value {
fn generate_transaction(pubkey: String) -> Value {
json!({
"from": pubkey,
"to": "Bob",
"amount": count
"amount": 1
})
}