简体   繁体   English

Solidity - 错误:标识符未找到或唯一

[英]Solidity - Error: identifier not found or unique

I tried to compile this code and it gives me an error (identifier not found or not unique ) why??我试图编译这段代码,但它给了我一个错误(标识符未找到或不唯一)为什么? please help me.. the concept of the code is adding an element in an array inside an array of struct and then search if an element exists to not I used a compiler 0.4.0请帮助我..代码的概念是在结构数组内的数组中添加一个元素,然后搜索一个元素是否存在我使用了编译器 0.4.0

pragma solidity ^0.4.0;
contract Ballot {
  struct EntityStruct {
    uint[] entityData;
    bool isEntity;
    bool iscontent;
    uint vote;
    uint predata;
    string isrep;
  }

    mapping(address => EntityStruct) public entityStructs;
    mapping(uint => entityData) public enitiyinfo;
    uint[] public datalist;
    address[] public entityList;

function newEntity(address entityAddress, uint entityDataa) public returns(uint rowNumber) {
   bytes32 datahash;
   uint counter = 0;
   datahash = keccak256(abi.encodePacked(entityDataa));
   for (uint i=0; i<entityList.length; i++)
   {
       for (uint y=0; y<datalist.length; y++)
       {
           
       if (datahash == keccak256(abi.encodePacked(entityStructs[entityList[i]].entityData[datalist[y]])))
       {
       counter = counter+1;
       }
   }
   }
 //  if (counter >0)
  // {
   require(counter == 0,"not aloowed!!");
   entityStructs[entityAddress].entityData.push(entityDataa);
  // entityStructs[entityAddress].entityData = entityDataa;
   entityStructs[entityAddress].isEntity = true;
   return entityList.push(entityAddress)-1;
   
   

}

function SearchForContent( uint data) public{
    uint rr = 0;
           for (uint i=0; i<entityList.length; i++) {
               for (uint y=0; y<5; y++)
               {
                   
               
               if ( data == entityStructs[entityList[i]].entityData[y])
               rr = rr+1;
           }
           require(rr >0,"not available data");
              // result = "available data";
               //else
            //require(data == entityStructs[entityList[i]].entityData,"notexsists data!!");
                          
}
}
}

The error is coming from line 13:错误来自第 13 行:

mapping(uint => entityData) public enitiyinfo;

Your entityData type is only defined in the scope of the EntityStruct struct: the rest of the program doesn't know what it is.您的entityData类型仅在EntityStruct结构的 scope 中定义:程序的 rest 不知道它是什么。 However, it looks like you never actually use the mapping in question, so you can just remove that line.但是,看起来您从未真正使用过有问题的映射,因此您可以删除该行。

Then your code compiles fine using v0.4.26.然后您的代码可以使用 v0.4.26 正常编译。 Some earlier 0.4.x versions do not support some of the features you use though, so you might want to reflect that in your pragma statement.某些较早的 0.4.x 版本不支持您使用的某些功能,因此您可能希望在pragma语句中反映这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM