-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29709c5
commit a201722
Showing
6 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use crate::{DBColumn, Error, StoreItem}; | ||
use ssz::{Decode, Encode}; | ||
use types::Hash256; | ||
|
||
pub const CURRENT_SCHEMA_VERSION: SchemaVersion = SchemaVersion(1); | ||
|
||
// All the keys that get stored under the `BeaconMeta` column. | ||
// | ||
// We use `repeat_byte` because it's a const fn. | ||
pub const SCHEMA_VERSION_KEY: Hash256 = Hash256::repeat_byte(0); | ||
pub const CONFIG_KEY: Hash256 = Hash256::repeat_byte(1); | ||
pub const SPLIT_KEY: Hash256 = Hash256::repeat_byte(2); | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
pub struct SchemaVersion(pub u64); | ||
|
||
impl StoreItem for SchemaVersion { | ||
fn db_column() -> DBColumn { | ||
DBColumn::BeaconMeta | ||
} | ||
|
||
fn as_store_bytes(&self) -> Vec<u8> { | ||
self.0.as_ssz_bytes() | ||
} | ||
|
||
fn from_store_bytes(bytes: &[u8]) -> Result<Self, Error> { | ||
Ok(SchemaVersion(u64::from_ssz_bytes(bytes)?)) | ||
} | ||
} |