Restore index as the guardian set naming convention
Change-Id: I531413d961a3fb0068bc278f72073497746f5eee
This commit is contained in:
parent
c1c778d65a
commit
aab930bfab
|
@ -1,6 +1,6 @@
|
||||||
use anchor_lang::{prelude::*, solana_program};
|
use anchor_lang::{prelude::*, solana_program};
|
||||||
|
|
||||||
use crate::{types::Version, MAX_LEN_GUARDIAN_KEYS};
|
use crate::{types::Index, MAX_LEN_GUARDIAN_KEYS};
|
||||||
|
|
||||||
#[account]
|
#[account]
|
||||||
pub struct BridgeInfo {}
|
pub struct BridgeInfo {}
|
||||||
|
@ -8,7 +8,7 @@ pub struct BridgeInfo {}
|
||||||
#[account]
|
#[account]
|
||||||
pub struct GuardianSetInfo {
|
pub struct GuardianSetInfo {
|
||||||
/// Version number of this guardian set.
|
/// Version number of this guardian set.
|
||||||
pub version: Version,
|
pub index: Index,
|
||||||
/// Number of keys stored
|
/// Number of keys stored
|
||||||
pub len_keys: u8,
|
pub len_keys: u8,
|
||||||
/// public key hashes of the guardian set
|
/// public key hashes of the guardian set
|
||||||
|
|
|
@ -3,7 +3,7 @@ use anchor_lang::{prelude::*, solana_program};
|
||||||
use crate::{
|
use crate::{
|
||||||
accounts,
|
accounts,
|
||||||
anchor_bridge::Bridge,
|
anchor_bridge::Bridge,
|
||||||
types::{BridgeConfig, Version},
|
types::{BridgeConfig, Index},
|
||||||
Initialize, InitializeData, MAX_LEN_GUARDIAN_KEYS,
|
Initialize, InitializeData, MAX_LEN_GUARDIAN_KEYS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,17 +13,17 @@ pub fn initialize(
|
||||||
initial_guardian_key: [[u8; 20]; MAX_LEN_GUARDIAN_KEYS],
|
initial_guardian_key: [[u8; 20]; MAX_LEN_GUARDIAN_KEYS],
|
||||||
config: BridgeConfig,
|
config: BridgeConfig,
|
||||||
) -> Result<Bridge, ProgramError> {
|
) -> Result<Bridge, ProgramError> {
|
||||||
let version = Version(0);
|
let index = Index(0);
|
||||||
|
|
||||||
// Initialize the Guardian Set for the first time.
|
// 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.creation_time = ctx.accounts.clock.unix_timestamp as u32;
|
||||||
ctx.accounts.guardian_set.keys = initial_guardian_key;
|
ctx.accounts.guardian_set.keys = initial_guardian_key;
|
||||||
ctx.accounts.guardian_set.len_keys = len_guardians;
|
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 {
|
Ok(Bridge {
|
||||||
guardian_set_version: version,
|
guardian_set_index: index,
|
||||||
config,
|
config,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ use anchor_lang::{prelude::*, solana_program};
|
||||||
use crate::{
|
use crate::{
|
||||||
accounts,
|
accounts,
|
||||||
anchor_bridge::Bridge,
|
anchor_bridge::Bridge,
|
||||||
types::{BridgeConfig, Version},
|
types::{BridgeConfig, Index},
|
||||||
PublishMessage,
|
PublishMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ pub mod anchor_bridge {
|
||||||
|
|
||||||
#[state]
|
#[state]
|
||||||
pub struct Bridge {
|
pub struct Bridge {
|
||||||
pub guardian_set_version: types::Version,
|
pub guardian_set_index: types::Index,
|
||||||
pub config: types::BridgeConfig,
|
pub config: types::BridgeConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use anchor_lang::prelude::*;
|
use anchor_lang::prelude::*;
|
||||||
|
|
||||||
// Distinguishes a Version number from a standard u32.
|
// Enforces a single bumping index number.
|
||||||
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
||||||
pub struct Version(pub u32);
|
pub struct Index(pub u32);
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Copy, Debug)]
|
||||||
|
|
Loading…
Reference in New Issue