File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
core/src/consensus/cuckoo Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ mod params;
1919use std:: cmp:: { max, min} ;
2020
2121use byteorder:: { ByteOrder , LittleEndian } ;
22+ use ccrypto:: blake256;
2223use ctypes:: U256 ;
2324use cuckoo:: Cuckoo as CuckooVerifier ;
2425use rlp:: UntrustedRlp ;
@@ -126,11 +127,14 @@ impl ConsensusEngine<CodeChainMachine> for Cuckoo {
126127 if !self . verifier . verify ( & message, & seal. proof ) {
127128 return Err ( From :: from ( BlockError :: InvalidProofOfWork ) )
128129 }
129- if U256 :: from ( header. hash ( ) ) > self . score_to_target ( header. score ( ) ) {
130+
131+ let target = self . score_to_target ( header. score ( ) ) ;
132+ let hash = blake256 ( :: rlp:: encode_list ( & seal. proof ) ) ;
133+ if U256 :: from ( hash) > target {
130134 return Err ( From :: from ( BlockError :: InvalidScore ( OutOfBounds {
131- min : Some ( * header . score ( ) ) ,
132- max : Some ( * header . score ( ) ) ,
133- found : U256 :: from ( header . hash ( ) ) ,
135+ min : Some ( target ) ,
136+ max : Some ( target ) ,
137+ found : U256 :: from ( hash) ,
134138 } ) ) )
135139 }
136140 Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments