James
Your statement before that any coin would be able to use the characteristics of any other coin in the network - that is by converting though instadex? Or natively? If natively, what would be the advantage of holding one net coin over the other, if they ca "do" the same things?
Each coin would implement the JSON handling specific to their coin, so when they receive the API command, they can process it.
The SuperNET is the transport
The services are applications
Easier to understand is telephone system. yes this is very good analogy.
There are local phone calls and long distance calls. The local calls are comms between people using the same coin. Long distance are comms between different coins. The area code is the coin.
Doesnt matter who you are calling, you can use the same phone connected to the same socket.
here is where it is not so exact, but thing of a service as a specific type of phone.
some phones have video, others have cameras, not exactly right, but hopefully you get the idea.
all the data is on the internect
all the different services are sending packets directly between two computers
each computer can properly decrypt all the packets sent to it and route the JSON request to the right service
Currently it requires changing the source code to add a new API call and of course the code to actually perform the API function.
I hope this is understandable, it is no easy to explain in english what should be a matter of showing some code fragments
current commands
static char **commands[] = { getpubkey, maketelepods, transporterstatus, telepod, transporter, tradebot, respondtx, processutx, publishaddrs, checkmsg, placebid, placeask, makeoffer, sendmsg, orderbook, getorderbooks, sellp, buyp, send, teleport, select };
example of one of the above
static char *teleport[] = { (char *)teleport_func, "teleport", "V", "NXT", "secret", "amount", "dest", "coin", "minage", "M", "N", 0 };
the "glue" function that actually calls the teleport function
char *teleport_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
double amount;
int32_t M,N;
struct coin_info *cp;
char NXTACCTSECRET[512],destaddr[512],minage[512],coinstr[512],*retstr = 0;
if ( Historical_done == 0 )
return(clonestr("historical processing is not done yet"));
copy_cJSON(NXTACCTSECRET,objs[1]);
amount = get_API_float(objs[2]);
copy_cJSON(destaddr,objs[3]);
copy_cJSON(coinstr,objs[4]);
copy_cJSON(minage,objs[5]);
M = get_API_int(objs[6],1);
N = get_API_int(objs[7],1);
if ( M > N || N >= 0xff || M <= 0 )
M = N = 1;
printf("amount.(%.8f) minage.(%s) %d | M.%d N.%d\n",amount,minage,atoi(minage),M,N);
cp = get_coin_info(coinstr);
if ( cp != 0 && sender[0] != 0 && amount > 0 && valid != 0 && destaddr[0] != 0 )
retstr = teleport(sender,NXTACCTSECRET,(uint64_t)(SATOSHIDEN * amount),destaddr,cp,atoi(minage),M,N);
else retstr = clonestr("{\"error\":\"invalid teleport request\"}");
return(retstr);
}
the teleport function, which triggers other API functions sometimes locally sometimes remotely, uses some genetic algo for telepod selection, etc.
char *teleport(char *NXTaddr,char *NXTACCTSECRET,uint64_t satoshis,char *otherpubaddr,struct coin_info *cp,int32_t minage,int32_t M,int32_t N)
{
static unsigned char zerokey[crypto_box_PUBLICKEYBYTES];
char buf[4096];
uint8_t sharenrs[255];
struct telepod **pods = 0;
struct NXT_acct *np,*destnp;
struct transporter_log *log;
int32_t n,err = -1;
uint32_t height;
if ( M <= 0 )
M = cp->M;
if ( N <= 0 )
N = cp->N;
if ( M <= 0 )
M = 1;
if ( N <= 0 )
N = 1;
memset(sharenrs,0,sizeof(sharenrs));
if ( N > 1 )
init_sharenrs(sharenrs,0,N,N);
sprintf(buf,"%s -> teleport %.8f %s -> %s minage.%d | M.%d N.%d dest.(%s)\n",NXTaddr,dstr(satoshis),cp->name,otherpubaddr,minage,M,N,otherpubaddr);
if ( minage == 0 )
minage = cp->minconfirms;
destnp = search_addresses(otherpubaddr);
height = (uint32_t)get_blockheight(cp);
if ( (pods= evolve_transporter(&n,0,cp,minage,satoshis,height)) == 0 )
sprintf(buf,"{\"error\":\"teleport: not enough for %.8f %s to %s\"}",dstr(satoshis),cp->name,otherpubaddr);
else
{
free(pods), pods = 0;
np = find_NXTacct(NXTaddr,NXTACCTSECRET);
if ( memcmp(destnp->pubkey,zerokey,sizeof(zerokey)) == 0 )
{
query_pubkey(destnp->H.NXTaddr,NXTACCTSECRET);
sprintf(buf,"{\"error\":\"no pubkey for %s, request sent\"}",otherpubaddr);
}
if ( memcmp(destnp->pubkey,zerokey,sizeof(zerokey)) != 0 )
{
printf("start evolving at %f\n",milliseconds());
pods = evolve_transporter(&n,cp->maxevolveiters,cp,minage,satoshis,height);
printf("finished evolving at %f\n",milliseconds());
if ( pods == 0 )
sprintf(buf,"{\"error\":\"unexpected transporter evolve failure for %.8f %s to %s\"}",dstr(satoshis),cp->name,otherpubaddr);
else
{
log = send_transporter_log(NXTaddr,cp->NXTACCTSECRET,destnp,cp,minage,satoshis,pods,n,M,N,sharenrs,otherpubaddr);
if ( log == 0 )
{
sprintf(buf,"{\"error\":\"unexpected error sending transporter log %.8f %s to %s\"}",dstr(satoshis),cp->name,otherpubaddr);
free(pods);
pods = 0;
}
else
{
err = 0;
sprintf(buf,"{\"result\":\"teleport AFTER CREATE BUNDLE to %s err.%d\"}",destnp->H.NXTaddr,err);
printf("teleport AFTER CREATE BUNDLE to %s err.%d\n",destnp->H.NXTaddr,err);
process_pingpong_queue(&Transporter_sendQ,log);
}
}
}
}
return(clonestr(buf));
}