Open banking ecosystem
Example heading with h2 size
Example heading with h3 size
Following is sample java code.
int i = 10;
if(i>0){
System.out.println('positive');
}
```pragma solidity ^0.8.0;
contract ThreatIntelligence {
struct Indicator {
string value;
uint timestamp;
address submitter;
uint upvotes;
uint downvotes;
bool isValidated;
}
mapping(bytes32 => Indicator) public indicators; // Hash of indicator value as key
mapping(address => uint) public reputation;
event IndicatorSubmitted(bytes32 hash, string value, address submitter, uint timestamp);
event IndicatorValidated(bytes32 hash, bool isValidated);
event VoteCast(bytes32 hash, address voter, bool isUpvote);
uint public validationThreshold = 5; // Number of upvotes needed for validation
function submitIndicator(string memory _value) public {
bytes32 hash = keccak256(bytes(_value));
require(indicators[hash].timestamp == 0, "Indicator already submitted.");
indicators[hash] = Indicator({
value: _value,
timestamp: block.timestamp,
submitter: msg.sender,
upvotes: 1,
downvotes: 0,
isValidated: false
});
reputation[msg.sender]++;
emit IndicatorSubmitted(hash, _value, msg.sender, block.timestamp);
}
function vote(string memory _value, bool _isUpvote) public {
bytes32 hash = keccak256(bytes(_value));
require(indicators[hash].timestamp > 0, "Indicator not found.");
// Prevent self-voting (optional)
require(indicators[hash].submitter != msg.sender, "Submitter cannot vote.");
// Prevent multiple votes from the same address (optional)
// require(!hasVoted[hash][msg.sender], "Already voted.");
// hasVoted[hash][msg.sender] = true;
if (_isUpvote) {
indicators[hash].upvotes++;
} else {
indicators[hash].downvotes++;
}
emit VoteCast(hash, msg.sender, _isUpvote);
_validateIndicator(hash);
}
function _validateIndicator(bytes32 _hash) internal {
if (!indicators[_hash].isValidated && indicators[_hash].upvotes >= validationThreshold) {
indicators[_hash].isValidated = true;
emit IndicatorValidated(_hash, true);
} else if (indicators[_hash].isValidated && indicators[_hash].upvotes < validationThreshold / 2) {
indicators[_hash].isValidated = false; // Revoke validation if downvoted significantly
emit IndicatorValidated(_hash, false);
}
}
function getIndicator(string memory _value) public view returns (Indicator memory) {
return indicators[keccak256(bytes(_value))];
}
}