Skip to content

Commit

Permalink
Use instance storage for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
cptartur committed May 10, 2024
1 parent 54f0e28 commit 431f60c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions contracts/governance/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ mod key_data;
pub(crate) fn read_layer(env: &Env, layer_id: &String) -> ContractResult<Layer> {
let key = get_layer_key(layer_id);
env.storage()
.temporary()
.instance()
.get(&key)
.ok_or(VotingSystemError::LayerMissing)
}

pub(crate) fn write_layer(env: &Env, layer_id: &String, layer: &Layer) {
let key = get_layer_key(layer_id);
env.storage().temporary().set(&key, layer);
env.storage().instance().set(&key, layer);
}

pub(crate) fn remove_layer(env: &Env, layer_id: &String) {
let key = get_layer_key(layer_id);
env.storage().temporary().remove(&key);
env.storage().instance().remove(&key);
}

pub(crate) fn read_neuron(
Expand All @@ -40,19 +40,19 @@ pub(crate) fn read_neuron(
) -> ContractResult<Neuron> {
let key = get_neuron_key(layer_id, neuron_id);
env.storage()
.temporary()
.instance()
.get(&key)
.ok_or(VotingSystemError::NeuronMissing)
}

pub(crate) fn write_neuron(env: &Env, layer_id: &String, neuron_id: &String, neuron: &Neuron) {
let key = get_neuron_key(layer_id, neuron_id);
env.storage().temporary().set(&key, neuron);
env.storage().instance().set(&key, neuron);
}

pub(crate) fn remove_neuron(env: &Env, layer_id: &String, neuron_id: &String) {
let key = get_neuron_key(layer_id, neuron_id);
env.storage().temporary().remove(&key);
env.storage().instance().remove(&key);
}

pub(crate) fn read_neuron_result(
Expand Down

0 comments on commit 431f60c

Please sign in to comment.