Add DateTime and Cancel conditions

Fixes #32, #33
This commit is contained in:
Greg Fitzgerald
2018-03-07 21:55:49 -07:00
parent dba6d7a8a6
commit 2379792e0a
4 changed files with 49 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ use historian::{reserve_signature, Historian};
use std::sync::mpsc::SendError;
use std::collections::HashMap;
use std::result;
use chrono::prelude::*;
#[derive(Debug, PartialEq, Eq)]
pub enum AccountingError {
@@ -138,6 +139,18 @@ impl Accountant {
self.process_transaction(tr).map(|_| sig)
}
pub fn transfer_on_date(
self: &mut Self,
n: i64,
keypair: &KeyPair,
to: PublicKey,
dt: DateTime<Utc>,
) -> Result<Signature> {
let tr = Transaction::new_on_date(keypair, to, dt, n, self.last_id);
let sig = tr.sig;
self.process_transaction(tr).map(|_| sig)
}
pub fn get_balance(self: &Self, pubkey: &PublicKey) -> Option<i64> {
self.balances.get(pubkey).map(|x| *x)
}