Skip to content

Commit

Permalink
Revert "Add migration code"
Browse files Browse the repository at this point in the history
This reverts commit 0aead15.
  • Loading branch information
neacsu committed Sep 9, 2021
1 parent e00e77d commit be56ae5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 40 deletions.
3 changes: 0 additions & 3 deletions common/mixnet-contract/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::fmt::Display;

use crate::current_block_height;

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
pub struct Gateway {
pub host: String,
Expand All @@ -26,7 +24,6 @@ pub struct GatewayBond {
pub bond_amount: Coin,
pub total_delegation: Coin,
pub owner: Addr,
#[serde(default = "current_block_height")]
pub block_height: u64,
pub gateway: Gateway,
}
Expand Down
7 changes: 0 additions & 7 deletions common/mixnet-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,3 @@ pub use gateway::{Gateway, GatewayBond, GatewayOwnershipResponse, PagedGatewayRe
pub use mixnode::{Layer, MixNode, MixNodeBond, MixOwnershipResponse, PagedMixnodeResponse};
pub use msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
pub use types::{IdentityKey, IdentityKeyRef, LayerDistribution, SphinxKey, StateParams};

use std::sync::atomic::{AtomicU64, Ordering};
pub static CURRENT_BLOCK_HEIGHT: AtomicU64 = AtomicU64::new(0);

pub fn current_block_height() -> u64 {
CURRENT_BLOCK_HEIGHT.load(Ordering::Relaxed)
}
3 changes: 0 additions & 3 deletions common/mixnet-contract/src/mixnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use std::fmt::Display;

use crate::current_block_height;

#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
pub struct MixNode {
pub host: String,
Expand Down Expand Up @@ -37,7 +35,6 @@ pub struct MixNodeBond {
pub total_delegation: Coin,
pub owner: Addr,
pub layer: Layer,
#[serde(default = "current_block_height")]
pub block_height: u64,
pub mix_node: MixNode,
}
Expand Down
28 changes: 1 addition & 27 deletions contracts/mixnet/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,33 +205,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<QueryResponse, Cont
}

#[entry_point]
pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
use crate::storage::{gateways, gateways_read, mixnodes, mixnodes_read};
use cosmwasm_std::{Order, StdResult};
use mixnet_contract::CURRENT_BLOCK_HEIGHT;
use mixnet_contract::{GatewayBond, MixNodeBond};
use std::sync::atomic::Ordering;

CURRENT_BLOCK_HEIGHT.store(env.block.height, Ordering::Relaxed);

let bonds = mixnodes_read(deps.storage)
.range(None, None, Order::Ascending)
.map(|res| res.map(|item| item.1))
.collect::<StdResult<Vec<MixNodeBond>>>()?;

for bond in bonds {
mixnodes(deps.storage).save(bond.identity().as_bytes(), &bond)?;
}

let bonds = gateways_read(deps.storage)
.range(None, None, Order::Ascending)
.map(|res| res.map(|item| item.1))
.collect::<StdResult<Vec<GatewayBond>>>()?;

for bond in bonds {
gateways(deps.storage).save(bond.identity().as_bytes(), &bond)?;
}

pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
Ok(Default::default())
}

Expand Down

0 comments on commit be56ae5

Please sign in to comment.