mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 23:27:56 -05:00
dao/spec: rename all mentions of slot to blockheight
This commit is contained in:
@@ -97,11 +97,11 @@ guarantee which block they get into, we therefore must modulo the block height
|
||||
a certain number which we use in the proofs.
|
||||
|
||||
```rust
|
||||
{{#include ../../../../../src/contract/dao/src/lib.rs:dao-slot_to_day}}
|
||||
{{#include ../../../../../src/contract/dao/src/lib.rs:dao-blockheight_to_day}}
|
||||
```
|
||||
|
||||
which can be used like this
|
||||
```rust
|
||||
{{#include ../../../../../src/contract/dao/src/entrypoint/propose.rs:dao-slot_to_day-example-usage}}
|
||||
{{#include ../../../../../src/contract/dao/src/entrypoint/propose.rs:dao-blockheight_to_day-example-usage}}
|
||||
```
|
||||
|
||||
|
||||
@@ -33,9 +33,10 @@ use darkfi_sdk::{
|
||||
use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
|
||||
|
||||
use crate::{
|
||||
blockheight_to_day,
|
||||
error::DaoError,
|
||||
model::{DaoBlindAggregateVote, DaoProposalMetadata, DaoProposeParams, DaoProposeUpdate},
|
||||
slot_to_day, DaoFunction, DAO_CONTRACT_DB_DAO_MERKLE_ROOTS, DAO_CONTRACT_DB_PROPOSAL_BULLAS,
|
||||
DaoFunction, DAO_CONTRACT_DB_DAO_MERKLE_ROOTS, DAO_CONTRACT_DB_PROPOSAL_BULLAS,
|
||||
DAO_CONTRACT_ZKAS_DAO_PROPOSE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_PROPOSE_MAIN_NS,
|
||||
};
|
||||
|
||||
@@ -83,9 +84,9 @@ pub(crate) fn dao_propose_get_metadata(
|
||||
));
|
||||
}
|
||||
|
||||
// ANCHOR: dao-slot_to_day-example-usage
|
||||
let current_day = slot_to_day(get_verifying_slot());
|
||||
// ANCHOR_END: dao-slot_to_day-example-usage
|
||||
// ANCHOR: dao-blockheight_to_day-example-usage
|
||||
let current_day = blockheight_to_day(get_verifying_slot());
|
||||
// ANCHOR_END: dao-blockheight_to_day-example-usage
|
||||
|
||||
let total_funds_coords = total_funds_commit.to_affine().coordinates().unwrap();
|
||||
zk_public_inputs.push((
|
||||
|
||||
@@ -30,9 +30,10 @@ use darkfi_sdk::{
|
||||
use darkfi_serial::{deserialize, serialize, Encodable, WriteExt};
|
||||
|
||||
use crate::{
|
||||
blockheight_to_day,
|
||||
error::DaoError,
|
||||
model::{DaoProposalMetadata, DaoVoteParams, DaoVoteUpdate},
|
||||
slot_to_day, DaoFunction, DAO_CONTRACT_DB_PROPOSAL_BULLAS, DAO_CONTRACT_DB_VOTE_NULLIFIERS,
|
||||
DaoFunction, DAO_CONTRACT_DB_PROPOSAL_BULLAS, DAO_CONTRACT_DB_VOTE_NULLIFIERS,
|
||||
DAO_CONTRACT_ZKAS_DAO_VOTE_BURN_NS, DAO_CONTRACT_ZKAS_DAO_VOTE_MAIN_NS,
|
||||
};
|
||||
|
||||
@@ -80,7 +81,7 @@ pub(crate) fn dao_vote_get_metadata(
|
||||
));
|
||||
}
|
||||
|
||||
let current_day = slot_to_day(get_verifying_slot());
|
||||
let current_day = blockheight_to_day(get_verifying_slot());
|
||||
|
||||
let yes_vote_commit_coords = params.yes_vote_commit.to_affine().coordinates().unwrap();
|
||||
let all_vote_commit_coords = all_vote_commit.to_affine().coordinates().unwrap();
|
||||
|
||||
@@ -90,13 +90,13 @@ pub const DAO_CONTRACT_ZKAS_DAO_AUTH_MONEY_TRANSFER_NS: &str = "DaoAuthMoneyTran
|
||||
pub const DAO_CONTRACT_ZKAS_DAO_AUTH_MONEY_TRANSFER_ENC_COIN_NS: &str =
|
||||
"DaoAuthMoneyTransferEncCoin";
|
||||
|
||||
// ANCHOR: dao-slot_to_day
|
||||
const SLOT_TIME: u64 = 90;
|
||||
// ANCHOR: dao-blockheight_to_day
|
||||
const BLOCK_TIME: u64 = 90;
|
||||
const SECS_IN_DAY: u64 = 24 * 60 * 60;
|
||||
|
||||
/// Days since genesis block. Used for time limit on DAO proposals.
|
||||
pub fn slot_to_day(slot: u64) -> u64 {
|
||||
let timestamp_secs = slot * SLOT_TIME;
|
||||
pub fn blockheight_to_day(height: u64) -> u64 {
|
||||
let timestamp_secs = height * BLOCK_TIME;
|
||||
timestamp_secs / SECS_IN_DAY
|
||||
}
|
||||
// ANCHOR_END: dao-slot_to_day
|
||||
// ANCHOR_END: dao-blockheight_to_day
|
||||
|
||||
Reference in New Issue
Block a user