extern void
ewmHandleTransferEvent (BREthereumEWM ewm,
                        BREthereumWallet wallet,
                        BREthereumTransfer transfer,
                        BREthereumTransferEvent event,
                        BREthereumStatus status,
                        const char *errorDescription) {

    // If `transfer` represents a token transfer that we've created/submitted, then we won't have
    // the actual `log` until the corresponding originating transaction is included.  We won't
    // have a hash (the log hash - based on the transaction hash + transaction index) and
    // we won't have data (the RLP encoding of the log).  Therefore there is literally nothing
    // to callback with `funcChangeLog`.
    //
    // Either we must a) create a log from the transaction (perhaps being willing to replace it
    // once the included log exists or b) avoid announcing `funcChangeLog:CREATED` until the
    // log is actually created....

    if (ewmNeedTransferSave (ewm, event)) {
        BREthereumTransaction transaction = transferGetBasisTransaction (transfer);
        BREthereumLog         log         = transferGetBasisLog(transfer);

        // If we have a hash, then we've got something to save.
        BREthereumHash hash = transferGetIdentifier(transfer);
        if (ETHEREUM_BOOLEAN_IS_FALSE (hashCompare (hash, EMPTY_HASH_INIT))) {

            // One of `transaction` or `log` will always be null
            assert (NULL == transaction || NULL == log);

            // We know that only on SIGNED do we have a transaction hash.  Only on
            // included do we have a log hash.  Thus we might see CHANGE_UPD w/o a
            // CHANGE_ADD - and that is NOT a problem.
            BREthereumClientChangeType type = ((event == TRANSFER_EVENT_CREATED ||
                                                event == TRANSFER_EVENT_SIGNED)
                                               ? CLIENT_CHANGE_ADD
                                               : (event == TRANSFER_EVENT_DELETED
                                                  ? CLIENT_CHANGE_REM
                                                  : CLIENT_CHANGE_UPD));

            if (NULL != transaction)
                ewmHandleSaveTransaction(ewm, transaction, type);

            if (NULL != log)
                ewmHandleSaveLog(ewm, log, type);
        }
    }

    // Announce the transfer
    ewm->client.funcTransferEvent (ewm->client.context,
                                   ewm,
                                   wallet,
                                   transfer,
                                   event,
                                   status,
                                   errorDescription);
}
示例#2
0
文件: item.cpp 项目: sun-lhy/PFHT
void insertItem(char *data)
{
	int i;
	int index;
	Link_Node_Ptr node;
	Link_Node_Ptr x = createNode(data);
	Link_Node_Ptr Y = insertNode(NULL,x);
	for(i=0;i<HASH_FUN_COUNT;i++)
	{
		if(hashCompare(i,x)==0)
		{
			int bucket = hashFun(i,(uint8_t*)x->data,strlen(x->data),HASH_TABLE_LEN);
			Y = insertNode(Hash_Table[bucket]->node,Y);
			Hash_Table[bucket]->node = NULL;
			Hash_Table[bucket]->counter ++;
		}
	}
	while((node=getNode(&Y)))
	{
		index = hashMinIndex(node);
		Hash_Table[index]->node = insertNode(Hash_Table[index]->node,node);
	}	
}