| 269 | } |
| 270 | |
| 271 | bool CheckScriptDB(int nheigh,string srcipt,string hash,int flag) |
| 272 | { |
| 273 | int curtiph = chainActive.Height(); |
| 274 | |
| 275 | string hash2 = "txid"; |
| 276 | |
| 277 | CRegID regid(srcipt); |
| 278 | if (regid.IsEmpty() == true) { |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | CContractDBCache contractScriptTemp(*pScriptDBTip, true); |
| 283 | if (!contractScriptTemp.HasContract(regid)) { |
| 284 | return false; |
| 285 | } |
| 286 | |
| 287 | vector<unsigned char> value; |
| 288 | vector<unsigned char> vScriptKey; |
| 289 | |
| 290 | uint256 hash1(value); |
| 291 | string pvalue(value.begin(),value.end()); |
| 292 | if(flag) |
| 293 | BOOST_CHECK(hash==hash1.GetHex()|| pvalue == hash2); |
| 294 | else{ |
| 295 | BOOST_CHECK(hash==hash1.GetHex()); |
| 296 | } |
| 297 | unsigned short key = 0; |
| 298 | memcpy(&key, &vScriptKey.at(0), sizeof(key)); |
| 299 | |
| 300 | int count = dbsize - 1; |
| 301 | while (count--) { |
| 302 | uint256 hash3(value); |
| 303 | string pvalue(value.begin(), value.end()); |
| 304 | if (flag) |
| 305 | BOOST_CHECK(hash == hash3.GetHex() || pvalue == hash2); |
| 306 | else { |
| 307 | BOOST_CHECK(hash == hash1.GetHex()); |
| 308 | } |
| 309 | } |
| 310 | return true; |
| 311 | } |
| 312 | |
| 313 | void CreateTx(string pcontact,string addr) |
| 314 | { |