@@ -591,11 +591,7 @@ pub fn benchmark_sr25519_verify(limit: ExecutionLimit) -> Throughput {
591591/// Optionally accepts a path to a `scratch_directory` to use to benchmark the
592592/// disk. Also accepts the `requirements` for the hardware benchmark and a
593593/// boolean to specify if the node is an authority.
594- pub fn gather_hwbench (
595- scratch_directory : Option < & Path > ,
596- requirements : Requirements ,
597- is_authority : bool ,
598- ) -> HwBench {
594+ pub fn gather_hwbench ( scratch_directory : Option < & Path > ) -> HwBench {
599595 #[ allow( unused_mut) ]
600596 let mut hwbench = HwBench {
601597 cpu_hashrate_score : benchmark_cpu ( DEFAULT_CPU_EXECUTION_LIMIT ) ,
@@ -625,42 +621,38 @@ pub fn gather_hwbench(
625621 } ;
626622 }
627623
628- if is_authority {
629- ensure_requirements ( hwbench. clone ( ) , requirements) ;
630- }
631-
632624 hwbench
633625}
634626
635- fn ensure_requirements ( hwbench : HwBench , requirements : Requirements ) {
636- let mut failed = 0 ;
637- for requirement in requirements. 0 . iter ( ) {
638- match requirement. metric {
639- Metric :: Blake2256 =>
640- if requirement. minimum > hwbench. cpu_hashrate_score {
641- failed += 1 ;
642- } ,
643- Metric :: MemCopy =>
644- if requirement. minimum > hwbench. memory_memcpy_score {
645- failed += 1 ;
646- } ,
647- Metric :: DiskSeqWrite =>
648- if let Some ( score) = hwbench. disk_sequential_write_score {
649- if requirement. minimum > score {
650- failed += 1 ;
651- }
652- } ,
653- Metric :: DiskRndWrite =>
654- if let Some ( score) = hwbench. disk_random_write_score {
655- if requirement. minimum > score {
656- failed += 1 ;
657- }
658- } ,
659- Metric :: Sr25519Verify => { } ,
627+ impl Requirements {
628+ /// Whether the hardware requirements are met by the provided benchmark results.
629+ pub fn check_hardware ( & self , hwbench : & HwBench ) -> bool {
630+ for requirement in self . 0 . iter ( ) {
631+ match requirement. metric {
632+ Metric :: Blake2256 =>
633+ if requirement. minimum > hwbench. cpu_hashrate_score {
634+ return false
635+ } ,
636+ Metric :: MemCopy =>
637+ if requirement. minimum > hwbench. memory_memcpy_score {
638+ return false
639+ } ,
640+ Metric :: DiskSeqWrite =>
641+ if let Some ( score) = hwbench. disk_sequential_write_score {
642+ if requirement. minimum > score {
643+ return false
644+ }
645+ } ,
646+ Metric :: DiskRndWrite =>
647+ if let Some ( score) = hwbench. disk_random_write_score {
648+ if requirement. minimum > score {
649+ return false
650+ }
651+ } ,
652+ Metric :: Sr25519Verify => { } ,
653+ }
660654 }
661- }
662- if failed != 0 {
663- log:: warn!( "⚠️ Your hardware performance score was less than expected for role 'Authority'. See https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware" ) ;
655+ true
664656 }
665657}
666658
0 commit comments