Skip to content

Commit

Permalink
check simply connected
Browse files Browse the repository at this point in the history
  • Loading branch information
easy-3dp authored and MikhailK committed Apr 18, 2024
1 parent 3134dad commit eca9c20
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
55 changes: 53 additions & 2 deletions runtime/src/check.rs
Original file line number Diff line number Diff line change
@@ -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<u8>, _hashes: &Vec<H256>) -> 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<u8>) -> 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
}
}
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eca9c20

Please sign in to comment.