Context independent CBlockHeader checks. fCheckPoW - Check proof-of-work. cur_time - Current time. Defaults to time.time() Raises CBlockHeaderError if block header is invalid.
(block_header, fCheckPoW = True, cur_time=None)
| 837 | |
| 838 | |
| 839 | def CheckBlockHeader(block_header, fCheckPoW = True, cur_time=None): |
| 840 | """Context independent CBlockHeader checks. |
| 841 | |
| 842 | fCheckPoW - Check proof-of-work. |
| 843 | |
| 844 | cur_time - Current time. Defaults to time.time() |
| 845 | |
| 846 | Raises CBlockHeaderError if block header is invalid. |
| 847 | """ |
| 848 | if cur_time is None: |
| 849 | cur_time = time.time() |
| 850 | |
| 851 | # Check proof-of-work matches claimed amount |
| 852 | if fCheckPoW: |
| 853 | CheckProofOfWork(block_header.GetHash(), block_header.nBits) |
| 854 | |
| 855 | # Check timestamp |
| 856 | if block_header.nTime > cur_time + 2 * 60 * 60: |
| 857 | raise CheckBlockHeaderError("CheckBlockHeader() : block timestamp too far in the future") |
| 858 | |
| 859 | |
| 860 | class CheckBlockError(CheckBlockHeaderError): |