Skip to content

src/processing/processing_validation_core.hpp

Header file of core implementation of processing task results validation. More...

Namespaces

Name
sgns
sgns::processing

Classes

Name
class sgns::processing::ProcessingValidationCore

Functions

Name
OUTCOME_HPP_DECLARE_ERROR_2(sgns::processing , ProcessingValidationCore::Error )
Macro for declaring error handling in the IBasicProof class.

Detailed Description

Header file of core implementation of processing task results validation.

Date: 2022-05-08 creativeid00

Note: This was mostly rewritten by Henrique A. Klein ([email protected]) and Justin Church ([email protected])

Functions Documentation

function OUTCOME_HPP_DECLARE_ERROR_2

OUTCOME_HPP_DECLARE_ERROR_2(
    sgns::processing ,
    ProcessingValidationCore::Error 
)

Macro for declaring error handling in the IBasicProof class.

Source code

#ifndef SUPERGENIUS_PROCESSING_VALIDATION_CORE_HPP
#define SUPERGENIUS_PROCESSING_VALIDATION_CORE_HPP

#include <map>
#include <string>
#include <set>
#include <vector>
#include <cstdint>

#include "outcome/outcome.hpp"
#include "base/logger.hpp"
#include "processing/proto/SGProcessing.pb.h"

namespace sgns::processing
{
    class ProcessingValidationCore
    {
    public:
        enum class Error
        {
            NO_RESULTS_FOR_SUBTASK = 0,  
            WRONG_RESULT_HASHES_LENGTH,  
            DUPLICATE_CHUNK_RESULT_HASH, 
            EMPTY_CHUNK_RESULT_HASH,     
            MISSING_CHUNK_RESULT,        
            INVALID_CHUNK_RESULT_HASH,   
            SUBTASK_ID_MISMATCH,         
            INVALID_RESULTS_BATCH        
        };
        ProcessingValidationCore();

        outcome::result<void> ValidateResults( const SGProcessing::SubTaskCollection                    &subTasks,
                                               const std::map<std::string, SGProcessing::SubTaskResult> &results,
                                               std::set<std::string> &invalidSubTaskIds );

        outcome::result<void> ValidateIndividualResult( const SGProcessing::SubTask       &subTask,
                                                        const SGProcessing::SubTaskResult &result ) const;

    private:
        outcome::result<void> CheckSubTaskResultHashes(
            const SGProcessing::SubTask                       &subTask,
            const std::map<std::string, std::vector<uint8_t>> &chunks ) const;

        base::Logger m_logger = base::createLogger( "ProcessingValidationCore" );
    };
}

OUTCOME_HPP_DECLARE_ERROR_2( sgns::processing, ProcessingValidationCore::Error );

#endif // SUPERGENIUS_PROCESSING_VALIDATION_CORE_HPP

Updated on 2026-03-04 at 13:10:44 -0800