Restore index as the guardian set naming convention

Change-Id: I531413d961a3fb0068bc278f72073497746f5eee
This commit is contained in:
Reisen 2021-04-30 02:52:59 +00:00
parent c1c778d65a
commit aab930bfab
5 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
use anchor_lang::{prelude::*, solana_program};
use crate::{types::Version, MAX_LEN_GUARDIAN_KEYS};
use crate::{types::Index, MAX_LEN_GUARDIAN_KEYS};
#[account]
pub struct BridgeInfo {}
@ -8,7 +8,7 @@ pub struct BridgeInfo {}
#[account]
pub struct GuardianSetInfo {
/// Version number of this guardian set.
pub version: Version,
pub index: Index,
/// Number of keys stored
pub len_keys: u8,
/// public key hashes of the guardian set

View File

@ -3,7 +3,7 @@ use anchor_lang::{prelude::*, solana_program};
use crate::{
accounts,
anchor_bridge::Bridge,
types::{BridgeConfig, Version},
types::{BridgeConfig, Index},
Initialize, InitializeData, MAX_LEN_GUARDIAN_KEYS,
};
@ -13,17 +13,17 @@ pub fn initialize(
initial_guardian_key: [[u8; 20]; MAX_LEN_GUARDIAN_KEYS],
config: BridgeConfig,
) -> Result<Bridge, ProgramError> {
let version = Version(0);
let index = Index(0);
// Initialize the Guardian Set for the first time.
ctx.accounts.guardian_set.version = version;
ctx.accounts.guardian_set.index = index;
ctx.accounts.guardian_set.creation_time = ctx.accounts.clock.unix_timestamp as u32;
ctx.accounts.guardian_set.keys = initial_guardian_key;
ctx.accounts.guardian_set.len_keys = len_guardians;
// Generate a Version 0 state for the bridges genesis.
// Create an initial bridge state, labeled index 0.
Ok(Bridge {
guardian_set_version: version,
guardian_set_index: index,
config,
})
}

View File

@ -3,7 +3,7 @@ use anchor_lang::{prelude::*, solana_program};
use crate::{
accounts,
anchor_bridge::Bridge,
types::{BridgeConfig, Version},
types::{BridgeConfig, Index},
PublishMessage,
};

View File

@ -106,7 +106,7 @@ pub mod anchor_bridge {
#[state]
pub struct Bridge {
pub guardian_set_version: types::Version,
pub guardian_set_index: types::Index,
pub config: types::BridgeConfig,
}

View File

@ -1,8 +1,8 @@
use anchor_lang::prelude::*;
// Distinguishes a Version number from a standard u32.
// Enforces a single bumping index number.
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
pub struct Version(pub u32);
pub struct Index(pub u32);
#[repr(C)]
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]