reporting/src/reporting.cpp
ACTION reporting::vote(uint64_t itemKey, name voter, uint64_t overall, uint64_t description, uint64_t service, uint64_t quality) {
	require_auth( voter );
	user_t users( _self, _self.value );
	auto it_voter = users.find(voter.value);
	check( !(it_voter->frozen) , "Your account is frozen." );
	check( it_voter->verificator, "You have no voting permission." );

	item_t item( _self, _self.value );
	auto it_item = item.find(itemKey);
	check( it_item->voteable, "You cannot vote for that." );
	check( !(it_item->reporter == voter), "You cannot vote for your own item." );
	check( !(it_item->appliable), "Applications are still open." );
	check( !(it_item->setvoters), "Voters are not determined." );

	voting_t voting( _self, _self.value );
	for(auto& row : voting) { 
	  check( !( row.itemKey == itemKey && row.voter == voter ), "You already voted for that item." ); 
	}
	
	bool activeVoter = 0;
	application_t application( _self, _self.value );
	for(auto& row : application) { 
	  if(row.itemKey == itemKey && row.applicant == voter && row.active == 1) {
	    activeVoter = 1;
	    break;
	  }
	}
	check(activeVoter, "You are no selected voter.");
	
	check((overall < 100 && description < 100 && service < 100 && quality < 100), "Only 2 digits per merit allowed.");
	uint64_t merit = overall * 1000000000 + description * 1000000 + service * 1000 + quality;
	
	bool voteConfirms = 1; if(overall < 1) { voteConfirms = 0; }
	bool isVoteable = 1; if (it_item->votes + 1 >= voteThreshold) { isVoteable = 0; }
	uint64_t reward_voter = it_item->reward / ( voteThreshold - it_item->votes );
	auto it_reporter = users.find(it_item->reporter.value);	
	
	users.modify(it_reporter, _self, [&]( auto& row ) { 
	  row.statusR = row.statusR + voteConfirms; 
	});
	users.modify(it_voter, _self, [&]( auto& row ) { 
	  row.statusV = row.statusV + 1; 
	  row.balance = row.balance + reward_voter;
	});
	voting.emplace(_self, [&]( auto& row ) { 
	  row.key = voting.available_primary_key(); 
	  row.itemKey = itemKey; 
	  row.voter = voter; 
	  row.value = merit; 
	});
	item.modify(it_item, _self, [&]( auto& row ) { 
	  row.confirmations = row.confirmations + voteConfirms; 
	  row.votes = row.votes + 1; 
	  row.rating = row.rating + merit; 
	  row.voteable = isVoteable; 
	  row.reward = row.reward - reward_voter;
	});
	
	if (!isVoteable && it_item->reward > 0) {
	  //transfer back leftovers of reward
	  users.modify(it_reporter, _self, [&]( auto& row ) { 
	    row.balance = row.balance + it_item->reward; 
	  });
	  item.modify(it_item, _self, [&]( auto& row ) { 
  	  row.reward = 0;
	  });
	}
	if (!isVoteable && it_item->confirmations < minConfirmations) { 
	  //item has no sufficient quality
	  item.modify(it_item, _self, [&]( auto& row ) { 
	    row.rating = 0; 
	  }); 
	}
	//appoint as verificator if enough status points are earned
	if(it_reporter->statusR >= statusThreshold) { 
	  reporting::appoint( it_reporter->user); 
	}
}
/**
 * Besides the report() method is this method the second core method.
 * After the the voters are selected these call this method to submit their assessment of the threat intelligence data. 
 * The assessment is done by the arguments overall, description, service and quality in the range [0; 99].
 * The voter is rewarded by a status point for his voting and an optional reward in token (if it was set from the reporter by the report() Method with the argument price)
 * The reporter gets his reward if the quality of the threat intelligence data was sufficient. Additionally the reporter earns for a positive rating a status point for reporting. 
 * If enough status points for reporting are earned the reporter gets the verifcation permission granted.
 * The last vote closes the assessment of the threat intelligence data and cleans up.
 */
Besides the report() method is this method the second core method.
After the the voters are selected these call this method to submit their assessment of the threat intelligence data.
The assessment is done by the arguments overall, description, service and quality in the range [0; 99].
The voter is rewarded by a status point for his voting and an optional reward in token (if it was set from the reporter by the report() Method with the argument price)
The reporter gets his reward if the quality of the threat intelligence data was sufficient. Additionally the reporter earns for a positive rating a status point for reporting.
If enough status points for reporting are earned the reporter gets the verifcation permission granted.
The last vote closes the assessment of the threat intelligence data and cleans up.
Besides the report () method is this method the second core method . After the the voters are selected these call this method to submit their assessment of the threat intelligence data . The assessment is done by the arguments overall description service and quality in the range [ 0 ; 99 ] . The voter is rewarded by a status point for his voting and an optional reward in token ( if it was set from the reporter by the report () Method with the argument price ) The reporter gets his reward if the quality of the threat intelligence data was sufficient . Additionally the reporter earns for a positive rating a status point for reporting . If enough status points for reporting are earned the reporter gets the verifcation permission granted . The last vote closes the assessment of the threat intelligence data and cleans up .
ACTION reporting::vote(uint64_t itemKey, name voter, uint64_t overall, uint64_t description, uint64_t service, uint64_t quality) {
	require_auth( voter );
	user_t users( _self, _self.value );
	auto it_voter = users.find(voter.value);
	check( !(it_voter->frozen) , "Your account is frozen." );
	check( it_voter->verificator, "You have no voting permission." );
	item_t item( _self, _self.value );
	auto it_item = item.find(itemKey);
	check( it_item->voteable, "You cannot vote for that." );
	check( !(it_item->reporter == voter), "You cannot vote for your own item." );
	check( !(it_item->appliable), "Applications are still open." );
	check( !(it_item->setvoters), "Voters are not determined." );
	voting_t voting( _self, _self.value );
	for(auto& row : voting) { 
	  check( !( row.itemKey == itemKey && row.voter == voter ), "You already voted for that item." ); 
	}
	bool activeVoter = 0;
	application_t application( _self, _self.value );
	for(auto& row : application) { 
	  if(row.itemKey == itemKey && row.applicant == voter && row.active == 1) {
	    activeVoter = 1;
	    break;
	  }
	}
	check(activeVoter, "You are no selected voter.");
	check((overall < 100 && description < 100 && service < 100 && quality < 100), "Only 2 digits per merit allowed.");
	uint64_t merit = overall * 1000000000 + description * 1000000 + service * 1000 + quality;
	bool voteConfirms = 1; if(overall < 1) { voteConfirms = 0; }
	bool isVoteable = 1; if (it_item->votes + 1 >= voteThreshold) { isVoteable = 0; }
	uint64_t reward_voter = it_item->reward / ( voteThreshold - it_item->votes );
	auto it_reporter = users.find(it_item->reporter.value);	
	users.modify(it_reporter, _self, [&]( auto& row ) { 
	  row.statusR = row.statusR + voteConfirms; 
	});
	users.modify(it_voter, _self, [&]( auto& row ) { 
	  row.statusV = row.statusV + 1; 
	  row.balance = row.balance + reward_voter;
	});
	voting.emplace(_self, [&]( auto& row ) { 
	  row.key = voting.available_primary_key(); 
	  row.itemKey = itemKey; 
	  row.voter = voter; 
	  row.value = merit; 
	});
	item.modify(it_item, _self, [&]( auto& row ) { 
	  row.confirmations = row.confirmations + voteConfirms; 
	  row.votes = row.votes + 1; 
	  row.rating = row.rating + merit; 
	  row.voteable = isVoteable; 
	  row.reward = row.reward - reward_voter;
	});
	if (!isVoteable && it_item->reward > 0) {
	  users.modify(it_reporter, _self, [&]( auto& row ) { 
	    row.balance = row.balance + it_item->reward; 
	  });
	  item.modify(it_item, _self, [&]( auto& row ) { 
  	  row.reward = 0;
	  });
	}
	if (!isVoteable && it_item->confirmations < minConfirmations) { 
	  item.modify(it_item, _self, [&]( auto& row ) { 
	    row.rating = 0; 
	  }); 
	}
	if(it_reporter->statusR >= statusThreshold) { 
	  reporting::appoint( it_reporter->user); 
	}
}
ACTION reporting :: vote ( uint64_t itemKey , name voter , uint64_t overall , uint64_t description , uint64_t service , uint64_t quality ) { require_auth ( voter ) ; user_t users ( _self , _self . value ) ; auto it_voter = users . find ( voter . value ) ; check ( ! ( it_voter -> frozen ) , " " ) ; check ( it_voter -> verificator , " " ) ; item_t item ( _self , _self . value ) ; auto it_item = item . find ( itemKey ) ; check ( it_item -> voteable , " " ) ; check ( ! ( it_item -> reporter == voter ) , " " ) ; check ( ! ( it_item -> appliable ) , " " ) ; check ( ! ( it_item -> setvoters ) , " " ) ; voting_t voting ( _self , _self . value ) ; for ( auto & row : voting ) { check ( ! ( row . itemKey == itemKey && row . voter == voter ) , " " ) ; } bool activeVoter = 0 ; application_t application ( _self , _self . value ) ; for ( auto & row : application ) { if ( row . itemKey == itemKey && row . applicant == voter && row . active == 1 ) { activeVoter = 1 ; break ; } } check ( activeVoter , " " ) ; check ( ( overall < 100 && description < 100 && service < 100 && quality < 100 ) , " " ) ; uint64_t merit = overall * 1000000000 + description * 1000000 + service * 1000 + quality ; bool voteConfirms = 1 ; if ( overall < 1 ) { voteConfirms = 0 ; } bool isVoteable = 1 ; if ( it_item -> votes + 1 >= voteThreshold ) { isVoteable = 0 ; } uint64_t reward_voter = it_item -> reward / ( voteThreshold - it_item -> votes ) ; auto it_reporter = users . find ( it_item -> reporter . value ) ; users . modify ( it_reporter , _self , [ & ] ( auto & row ) { row . statusR = row . statusR + voteConfirms ; } ) ; users . modify ( it_voter , _self , [ & ] ( auto & row ) { row . statusV = row . statusV + 1 ; row . balance = row . balance + reward_voter ; } ) ; voting . emplace ( _self , [ & ] ( auto & row ) { row . key = voting . available_primary_key ( ) ; row . itemKey = itemKey ; row . voter = voter ; row . value = merit ; } ) ; item . modify ( it_item , _self , [ & ] ( auto & row ) { row . confirmations = row . confirmations + voteConfirms ; row . votes = row . votes + 1 ; row . rating = row . rating + merit ; row . voteable = isVoteable ; row . reward = row . reward - reward_voter ; } ) ; if ( ! isVoteable && it_item -> reward > 0 ) { users . modify ( it_reporter , _self , [ & ] ( auto & row ) { row . balance = row . balance + it_item -> reward ; } ) ; item . modify ( it_item , _self , [ & ] ( auto & row ) { row . reward = 0 ; } ) ; } if ( ! isVoteable && it_item -> confirmations < minConfirmations ) { item . modify ( it_item , _self , [ & ] ( auto & row ) { row . rating = 0 ; } ) ; } if ( it_reporter -> statusR >= statusThreshold ) { reporting :: appoint ( it_reporter -> user ) ; } }
Besides the report() method is this method the second core method.
Besides the report () method is this method the second core method .
//transfer back leftovers of reward //item has no sufficient quality //appoint as verificator if enough status points are earned