MCPcopy Create free account
hub / github.com/albertobsd/keyhunt / forceReadFileAddressEth

Function forceReadFileAddressEth

keyhunt.cpp:6374–6450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6372}
6373
6374bool forceReadFileAddressEth(char *fileName) {
6375 /* Here we read the original file as usual */
6376 FILE *fileDescriptor;
6377 bool validAddress;
6378 uint64_t numberItems,i;
6379 size_t r;
6380 uint8_t rawvalue[50];
6381 char aux[100],*hextemp;
6382 fileDescriptor = fopen(fileName,"r");
6383 if(fileDescriptor == NULL) {
6384 fprintf(stderr,"[E] Error opening the file %s, line %i\n",fileName,__LINE__ - 2);
6385 return false;
6386 }
6387 /*Count lines in the file*/
6388 numberItems = 0;
6389 while(!feof(fileDescriptor)) {
6390 hextemp = fgets(aux,100,fileDescriptor);
6391 trim(aux," \t\n\r");
6392 if(hextemp == aux) {
6393 r = strlen(aux);
6394 if(r >= 40) {
6395 numberItems++;
6396 }
6397 }
6398 }
6399 fseek(fileDescriptor,0,SEEK_SET);
6400
6401 MAXLENGTHADDRESS = 20; /*20 bytes beacuase we only need the data in binary*/
6402 N = numberItems;
6403
6404 printf("[+] Allocating memory for %" PRIu64 " elements: %.2f MB\n",numberItems,(double)(((double) sizeof(struct address_value)*numberItems)/(double)1048576));
6405 addressTable = (struct address_value*) malloc(sizeof(struct address_value)*numberItems);
6406 checkpointer((void *)addressTable,__FILE__,"malloc","addressTable" ,__LINE__ -1 );
6407
6408
6409 if(!initBloomFilter(&bloom,N))
6410 return false;
6411
6412 i = 0;
6413 while(i < numberItems) {
6414 validAddress = false;
6415 memset(aux,0,100);
6416 memset(addressTable[i].value,0,sizeof(struct address_value));
6417 hextemp = fgets(aux,100,fileDescriptor);
6418 trim(aux," \t\n\r");
6419 r = strlen(aux);
6420 if(r >= 40 && r <= 42){
6421 switch(r) {
6422 case 40:
6423 if(isValidHex(aux)){
6424 hexs2bin(aux,rawvalue);
6425 bloom_add(&bloom, rawvalue ,sizeof(struct address_value));
6426 memcpy(addressTable[i].value,rawvalue,sizeof(struct address_value));
6427 i++;
6428 validAddress = true;
6429 }
6430 break;
6431 case 42:

Callers 1

readFileAddressFunction · 0.70

Calls 6

trimFunction · 0.85
isValidHexFunction · 0.85
hexs2binFunction · 0.85
bloom_addFunction · 0.85
checkpointerFunction · 0.70
initBloomFilterFunction · 0.70

Tested by

no test coverage detected