test
This commit is contained in:
@@ -92,6 +92,8 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
try
|
||||
{
|
||||
void komodo_args();
|
||||
komodo_args();
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
@@ -114,7 +116,15 @@ bool AppInit(int argc, char* argv[])
|
||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||
USE_EXTERNAL_PUBKEY = 1;
|
||||
fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str());
|
||||
|
||||
char *dirname;
|
||||
while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 )
|
||||
{
|
||||
fprintf(stderr,"waiting for datadir\n");
|
||||
sleep(3);
|
||||
}
|
||||
fprintf(stderr,"Got datadir.(%s)\n",dirname);
|
||||
komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1);
|
||||
|
||||
// Command-line RPC
|
||||
bool fCommandLine = false;
|
||||
for (int i = 1; i < argc; i++)
|
||||
|
||||
10
src/komodo.h
10
src/komodo.h
@@ -28,7 +28,15 @@ void komodo_init();
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *method,char *params,uint16_t port);
|
||||
|
||||
int32_t ASSETCHAINS_SHORTFLAG,NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000;
|
||||
int32_t ASSETCHAINS_SHORTFLAG;
|
||||
char ASSETCHAINS_SYMBOL[16];
|
||||
uint16_t ASSETCHAINS_PORT = 8777;
|
||||
uint32_t ASSETCHAIN_INIT = 0;
|
||||
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
||||
uint32_t ASSETCHAINS_TIMESTAMP = 1475772963;
|
||||
uint64_t ASSETCHAINS_SUPPLY = 1000000;
|
||||
|
||||
int32_t NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000;
|
||||
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
|
||||
pthread_mutex_t komodo_mutex;
|
||||
uint32_t KOMODO_INITDONE;
|
||||
|
||||
@@ -1086,89 +1086,6 @@ void OS_randombytes(unsigned char *x,long xlen)
|
||||
}
|
||||
}
|
||||
|
||||
void komodo_userpass(char *username,char *password,FILE *fp)
|
||||
{
|
||||
char *rpcuser,*rpcpassword,*str,line[8192];
|
||||
rpcuser = rpcpassword = 0;
|
||||
username[0] = password[0] = 0;
|
||||
while ( fgets(line,sizeof(line),fp) != 0 )
|
||||
{
|
||||
if ( line[0] == '#' )
|
||||
continue;
|
||||
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
|
||||
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
||||
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
||||
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
|
||||
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
|
||||
}
|
||||
if ( rpcuser != 0 && rpcpassword != 0 )
|
||||
{
|
||||
strcpy(username,rpcuser);
|
||||
strcpy(password,rpcpassword);
|
||||
}
|
||||
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
|
||||
if ( rpcuser != 0 )
|
||||
free(rpcuser);
|
||||
if ( rpcpassword != 0 )
|
||||
free(rpcpassword);
|
||||
}
|
||||
|
||||
void komodo_configfile(char *symbol,uint16_t port)
|
||||
{
|
||||
static char myusername[512],mypassword[8192];
|
||||
FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
|
||||
r = (uint32_t)time(NULL);
|
||||
r2 = OS_milliseconds();
|
||||
memcpy(buf,&r,sizeof(r));
|
||||
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
|
||||
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
|
||||
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
|
||||
OS_randombytes(buf2,sizeof(buf2));
|
||||
for (i=0; i<sizeof(buf2); i++)
|
||||
sprintf(&password[i*2],"%02x",buf2[i]);
|
||||
password[i*2] = 0;
|
||||
sprintf(buf,"%s.conf",symbol);
|
||||
BITCOIND_PORT = port;
|
||||
#ifdef WIN32
|
||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
|
||||
#else
|
||||
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
|
||||
#endif
|
||||
if ( (fp= fopen(fname,"rb")) == 0 )
|
||||
{
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nbind=127.0.0.1\n",crc,password,port);
|
||||
fclose(fp);
|
||||
printf("Created (%s)\n",fname);
|
||||
} else printf("Couldnt create (%s)\n",fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
komodo_userpass(myusername,mypassword,fp);
|
||||
mapArgs["-rpcpassword"] = mypassword;
|
||||
mapArgs["-rpcusername"] = myusername;
|
||||
fclose(fp);
|
||||
}
|
||||
strcpy(fname,GetDataDir(false).string().c_str());
|
||||
#ifdef WIN32
|
||||
while ( fname[strlen(fname)-1] != '\\' )
|
||||
fname[strlen(fname)-1] = 0;
|
||||
strcat(fname,".komodo/komodo.conf");
|
||||
#else
|
||||
while ( fname[strlen(fname)-1] != '/' )
|
||||
fname[strlen(fname)-1] = 0;
|
||||
strcat(fname,".komodo/komodo.conf");
|
||||
#endif
|
||||
printf("KOMODO.(%s)\n",fname);
|
||||
if ( (fp= fopen(fname,"rb")) != 0 )
|
||||
{
|
||||
komodo_userpass(username,password,fp);
|
||||
sprintf(KMDUSERPASS,"%s:%s",username,password);
|
||||
fclose(fp);
|
||||
} else printf("couldnt open.(%s)\n",fname);
|
||||
}
|
||||
|
||||
void lock_queue(queue_t *queue)
|
||||
{
|
||||
if ( queue->initflag == 0 )
|
||||
@@ -1282,3 +1199,114 @@ void iguana_initQ(queue_t *Q,char *name)
|
||||
if ( (item= queue_dequeue(Q)) != 0 )
|
||||
free(item);
|
||||
}
|
||||
|
||||
void komodo_userpass(char *username,char *password,FILE *fp)
|
||||
{
|
||||
char *rpcuser,*rpcpassword,*str,line[8192];
|
||||
rpcuser = rpcpassword = 0;
|
||||
username[0] = password[0] = 0;
|
||||
while ( fgets(line,sizeof(line),fp) != 0 )
|
||||
{
|
||||
if ( line[0] == '#' )
|
||||
continue;
|
||||
//printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword"));
|
||||
if ( (str= strstr(line,(char *)"rpcuser")) != 0 )
|
||||
rpcuser = parse_conf_line(str,(char *)"rpcuser");
|
||||
else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 )
|
||||
rpcpassword = parse_conf_line(str,(char *)"rpcpassword");
|
||||
}
|
||||
if ( rpcuser != 0 && rpcpassword != 0 )
|
||||
{
|
||||
strcpy(username,rpcuser);
|
||||
strcpy(password,rpcpassword);
|
||||
}
|
||||
//printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port);
|
||||
if ( rpcuser != 0 )
|
||||
free(rpcuser);
|
||||
if ( rpcpassword != 0 )
|
||||
free(rpcpassword);
|
||||
}
|
||||
|
||||
void komodo_configfile(char *symbol,uint16_t port)
|
||||
{
|
||||
static char myusername[512],mypassword[8192];
|
||||
FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i;
|
||||
r = (uint32_t)time(NULL);
|
||||
r2 = OS_milliseconds();
|
||||
memcpy(buf,&r,sizeof(r));
|
||||
memcpy(&buf[sizeof(r)],&r2,sizeof(r2));
|
||||
memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol));
|
||||
crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol)));
|
||||
OS_randombytes(buf2,sizeof(buf2));
|
||||
for (i=0; i<sizeof(buf2); i++)
|
||||
sprintf(&password[i*2],"%02x",buf2[i]);
|
||||
password[i*2] = 0;
|
||||
sprintf(buf,"%s.conf",symbol);
|
||||
BITCOIND_PORT = port;
|
||||
#ifdef WIN32
|
||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
|
||||
#else
|
||||
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf);
|
||||
#endif
|
||||
if ( (fp= fopen(fname,"rb")) == 0 )
|
||||
{
|
||||
if ( (fp= fopen(fname,"wb")) != 0 )
|
||||
{
|
||||
fprintf(fp,"rpcuser=user%u\nrpcpassword=pass%s\nrpcport=%u\nserver=1\ntxindex=1\nbind=127.0.0.1\n",crc,password,port);
|
||||
fclose(fp);
|
||||
printf("Created (%s)\n",fname);
|
||||
} else printf("Couldnt create (%s)\n",fname);
|
||||
}
|
||||
else
|
||||
{
|
||||
komodo_userpass(myusername,mypassword,fp);
|
||||
mapArgs["-rpcpassword"] = mypassword;
|
||||
mapArgs["-rpcusername"] = myusername;
|
||||
fclose(fp);
|
||||
}
|
||||
strcpy(fname,GetDataDir(false).string().c_str());
|
||||
#ifdef WIN32
|
||||
while ( fname[strlen(fname)-1] != '\\' )
|
||||
fname[strlen(fname)-1] = 0;
|
||||
strcat(fname,".komodo/komodo.conf");
|
||||
#else
|
||||
while ( fname[strlen(fname)-1] != '/' )
|
||||
fname[strlen(fname)-1] = 0;
|
||||
strcat(fname,".komodo/komodo.conf");
|
||||
#endif
|
||||
printf("KOMODO.(%s)\n",fname);
|
||||
if ( (fp= fopen(fname,"rb")) != 0 )
|
||||
{
|
||||
komodo_userpass(username,password,fp);
|
||||
sprintf(KMDUSERPASS,"%s:%s",username,password);
|
||||
fclose(fp);
|
||||
} else printf("couldnt open.(%s)\n",fname);
|
||||
}
|
||||
|
||||
void komodo_args()
|
||||
{
|
||||
std::string name;
|
||||
ASSETCHAINS_TIMESTAMP = GetArg("-ac_timestamp",ASSETCHAINS_TIMESTAMP);
|
||||
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
|
||||
name = GetArg("-ac_name","REVS");
|
||||
strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1);
|
||||
uint8_t buf[512]; int32_t i,len;
|
||||
len = iguana_rwnum(1,buf,sizeof(ASSETCHAINS_TIMESTAMP),(void *)&ASSETCHAINS_TIMESTAMP);
|
||||
len += iguana_rwnum(1,&buf[len],sizeof(ASSETCHAINS_SUPPLY),(void *)&ASSETCHAINS_SUPPLY);
|
||||
strcpy((char *)&buf[len],ASSETCHAINS_SYMBOL);
|
||||
len += strlen(ASSETCHAINS_SYMBOL);
|
||||
ASSETCHAINS_MAGIC = calc_crc32(0,buf,len);
|
||||
ASSETCHAINS_PORT = GetArg("-ac_port",8000 + (ASSETCHAINS_MAGIC % 7777));
|
||||
if ( ASSETCHAINS_SYMBOL[0] == '-' )
|
||||
{
|
||||
ASSETCHAINS_SHORTFLAG = 1;
|
||||
for (i=0; ASSETCHAINS_SYMBOL[i+1]!=0; i++)
|
||||
ASSETCHAINS_SYMBOL[i] = ASSETCHAINS_SYMBOL[i+1];
|
||||
}
|
||||
fprintf(stderr,"after args: %c%s port.%u magic.%08x timestamp.%u supply.%u\n",ASSETCHAINS_SHORTFLAG!=0?'-':'+',ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT,ASSETCHAINS_MAGIC,ASSETCHAINS_TIMESTAMP,(int32_t)ASSETCHAINS_SUPPLY);
|
||||
while ( 0 && ASSETCHAIN_INIT == 0 )
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
fprintf(stderr,"%s chain params initialized\n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
|
||||
boost::filesystem::path pathLogDir = pathIn / "database";
|
||||
TryCreateDirectory(pathLogDir);
|
||||
boost::filesystem::path pathErrorFile = pathIn / "db.log";
|
||||
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s\n", pathLogDir.string(), pathErrorFile.string());
|
||||
LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s pathIn.(%s)\n", pathLogDir.string(), pathErrorFile.string(),pathIn.string());
|
||||
fprintf(stderr,"strPath.(%s)\n",strPath.c_str());
|
||||
|
||||
unsigned int nEnvFlags = 0;
|
||||
|
||||
Reference in New Issue
Block a user