Browse Source

test

pull/4/head
jl777 8 years ago
parent
commit
a18fbdc541
  1. 2
      src/komodo_notary.h
  2. 17
      src/komodo_utils.h

2
src/komodo_notary.h

@ -198,6 +198,8 @@ void komodo_init()
if ( didinit == 0 )
{
didinit = 1;
iguana_initQ(&DepositsQ,"Deposits");
iguana_initQ(&PendingsQ,"Pendings");
pthread_mutex_init(&komodo_mutex,NULL);
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
n = (int32_t)(sizeof(Notaries)/sizeof(*Notaries));

17
src/komodo_utils.h

@ -16,6 +16,13 @@
#define SATOSHIDEN ((uint64_t)100000000L)
#define dstr(x) ((double)(x) / SATOSHIDEN)
typedef struct queue
{
struct queueitem *list;
portable_mutex_t mutex;
char name[64],initflag;
} queue_t;
union _bits256 { uint8_t bytes[32]; uint16_t ushorts[16]; uint32_t uints[8]; uint64_t ulongs[4]; uint64_t txid; };
typedef union _bits256 bits256;
@ -1216,3 +1223,13 @@ int32_t queue_size(queue_t *queue)
portable_mutex_unlock(&queue->mutex);
return count;
}
void iguana_initQ(queue_t *Q,char *name)
{
char *tst,*str = "need to init each Q when single threaded";
memset(Q,0,sizeof(*Q));
strcpy(Q->name,name);
queue_enqueue(name,Q,queueitem(str),1);
if ( (tst= queue_dequeue(Q,1)) != 0 )
free_queueitem(tst);
}

Loading…
Cancel
Save