Browse Source

Active api

patch-3
jl777 7 years ago
parent
commit
79d39e3cef
  1. 18
      iguana/iguana_notary.c
  2. 2
      iguana/tests/active

18
iguana/iguana_notary.c

@ -857,6 +857,8 @@ STRING_AND_INT(dpow,fundnotaries,symbol,numblocks)
return(clonestr("{\"result\":\"success\"}")); return(clonestr("{\"result\":\"success\"}"));
} }
extern char *Notaries_elected[65][2];
STRING_ARG(dpow,active,maskhex) STRING_ARG(dpow,active,maskhex)
{ {
uint8_t data[8],revdata[8],pubkeys[64][33]; char pubkeystr[67]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array = cJSON_CreateArray(); uint8_t data[8],revdata[8],pubkeys[64][33]; char pubkeystr[67]; int32_t i,len,current,n; uint64_t mask; cJSON *infojson,*retjson,*array = cJSON_CreateArray();
@ -874,7 +876,7 @@ STRING_ARG(dpow,active,maskhex)
if ( ((1LL << i) & mask) != 0 ) if ( ((1LL << i) & mask) != 0 )
{ {
init_hexbytes_noT(pubkeystr,pubkeys[i],33); init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr); //printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr); jaddistr(array,pubkeystr);
} }
} }
@ -883,7 +885,7 @@ STRING_ARG(dpow,active,maskhex)
jadd(retjson,"notaries",array); jadd(retjson,"notaries",array);
return(jprint(retjson,1)); return(jprint(retjson,1));
} }
printf("dpow active (%s)\n",maskhex); //printf("dpow active (%s)\n",maskhex);
if ( (len= (int32_t)strlen(maskhex)) <= 16 ) if ( (len= (int32_t)strlen(maskhex)) <= 16 )
{ {
len >>= 1; len >>= 1;
@ -893,15 +895,15 @@ STRING_ARG(dpow,active,maskhex)
revdata[i] = data[len-1-i]; revdata[i] = data[len-1-i];
mask = 0; mask = 0;
memcpy(&mask,revdata,sizeof(revdata)); memcpy(&mask,revdata,sizeof(revdata));
for (i=0; i<len; i++) //for (i=0; i<len; i++)
printf("%02x",data[i]); // printf("%02x",data[i]);
printf(" <- hex mask.%llx\n",(long long)mask); //printf(" <- hex mask.%llx\n",(long long)mask);
for (i=0; i<(len<<3); i++) for (i=0; i<(len<<3); i++)
if ( ((1LL << i) & mask) != 0 ) if ( ((1LL << i) & mask) != 0 )
{ {
init_hexbytes_noT(pubkeystr,pubkeys[i],33); //init_hexbytes_noT(pubkeystr,pubkeys[i],33);
printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr); //printf("(%d %llx %s) ",i,(long long)(1LL << i),pubkeystr);
jaddistr(array,pubkeystr); jaddistr(array,Notaries_elected[i][0]);
} }
return(jprint(array,1)); return(jprint(array,1));
} else return(clonestr("{\"error\":\"maskhex too long\"}")); } else return(clonestr("{\"error\":\"maskhex too long\"}"));

2
iguana/tests/active

@ -0,0 +1,2 @@
#!/bin/bash
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"dpow\",\"method\":\"active\",\"maskhex\":\"7fc27f67df27e619\"}"
Loading…
Cancel
Save