diff --git a/runtime/src/check.rs b/runtime/src/check.rs index a9a47f64..1bf44116 100644 --- a/runtime/src/check.rs +++ b/runtime/src/check.rs @@ -1,7 +1,58 @@ use sp_core::H256; use sp_std::vec::Vec; +use sp_std::str::from_utf8; +use sp_std::collections::btree_set; pub(crate) fn check_obj(_alg_id: &[u8;16], _obj: &Vec, _hashes: &Vec) -> bool { - // TODO: additional validation - true + + use sp_std::vec; + use sp_consensus_poscan::decompress_obj; + + let mut obj = _obj.clone(); + + if obj[..4] == vec![b'l', b'z', b's', b's'] { + obj = decompress_obj(&obj[4..]); + } + + check_simply_connected(&obj) } + +fn check_simply_connected(obj: &Vec) -> bool { + if let Ok(text) = from_utf8(&obj) { + let mut vs_list = btree_set::BTreeSet::new();//::with_capacity(6000); + for line in text.lines() { + let words: Vec<&str> = line.split_whitespace().collect(); + if words.len() > 0 { + match words[0] { + "f" => { + if words.len() == 4 { + let mut vs = [0,0,0]; + for idx in 1..=3 { + let swords: Vec<&str> = words[idx].split("/").collect(); + if swords.len() == 3 { + if let Ok(i) = swords[0].parse() { + vs[idx-1] = i; + } + } + } + if vs_list.is_empty() + || vs_list.contains(&vs[0]) + || vs_list.contains(&vs[1]) + || vs_list.contains(&vs[2]) { + vs_list.insert(vs[0]); + vs_list.insert(vs[1]); + vs_list.insert(vs[2]); + } else { + return false; + } + } + }, + _=>{}, + } + } + } + true + } else { + false + } +} \ No newline at end of file diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f08bd4e9..1dfc2d05 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -148,7 +148,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 123, + spec_version: 124, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,