-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added timestamp to wallet #152
Conversation
Signed-off-by: muraca <mmuraca247@gmail.com>
224fd2f
to
1f407e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good. Made a couple little suggestions. Take them or leave them.
wallet/src/sync.rs
Outdated
// For now the wallet only supports simple coins and timestamp | ||
match output.payload.type_id { | ||
Coin::<0>::TYPE_ID => { | ||
let amount = output.payload.extract::<Coin<0>>()?.0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a good time to make the filtering we do here paramaterizeable like the verifier filter is above. Or at least make a follow up issue for it.
wallet/src/sync.rs
Outdated
|
||
pub(crate) fn get_timestamp(db: &Db) -> anyhow::Result<u64> { | ||
let timestamp_tree = db.open_tree(TIMESTAMP)?; | ||
let timestamp = timestamp_tree | ||
.get([0])? | ||
.ok_or_else(|| anyhow!("Could not find timestamp in database."))?; | ||
u64::decode(&mut ×tamp[..]) | ||
.map_err(|_| anyhow!("Could not decode timestamp from database.")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this would go in a separate timestamp module. My idea is that logic associated with each piece (like how this is associated with the timestamp piece) will live in a dedicated file. That should make it easy to make chain-specific wallets by either including or not including that part of the wallet.
Signed-off-by: muraca <mmuraca247@gmail.com>
introduced fn `apply_transaction` for pieces Signed-off-by: muraca <mmuraca247@gmail.com>
match output.payload.type_id { | ||
Coin::<0>::TYPE_ID => { | ||
crate::money::apply_transaction(db, tx_hash, index as u32, output)?; | ||
} | ||
Timestamp::TYPE_ID => { | ||
crate::timestamp::apply_transaction(db, output)?; | ||
} | ||
_ => return Err(anyhow!("{:?}", ())), | ||
_ => continue, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshOrndorff I like this approach better, please check it out.
Signed-off-by: muraca <mmuraca247@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for improving the wallet structure!
This is useful to check that #151 is working as expected.