Example #1
0
void add_outgoing(struct Array *base, struct Node *target){
	add_to_array(base, target);
	if(target->type != 'h'){ // hubs are added with their outgoing nodes attached
		for(int i = 0; i < target->outgoing_len; i++){
			if(target->outgoing[i].relation == 'm'){ // multiple links add hubs
				add_to_array(base, target->outgoing[i].custom);
			} 
			else if(target->outgoing[i].relation == 'c'){ // custom links add custom nodes
				add_outgoing(base, target->outgoing[i].custom);	
			} 
			else if(target->outgoing[i].relation != 'n'){
				add_outgoing(base, target->outgoing[i].target);
			}
		}
	}
}
Example #2
0
struct Array *compile_states(struct Node *node){
	struct Array *result = (struct Array *) malloc(sizeof(struct Array));
	result->outgoing_len = 0;
	result->outgoing = (struct Node *) malloc(sizeof(struct Node));
	add_outgoing(result, node);
	return result;
};
Example #3
0
bool Blockchain::StoreOutgoing(
    const Identifier& senderNymID,
    const Identifier& accountID,
    const Identifier& recipientContactID,
    const proto::BlockchainTransaction& transaction) const
{
    LOCK_ACCOUNT()

    const std::string sNymID = senderNymID.str();
    const std::string sAccountID = accountID.str();
    auto account = load_account(accountLock, sNymID, sAccountID);

    if (false == bool(account)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Account does not exist."
              << std::endl;

        return false;
    }

    const auto& txid = transaction.txid();
    account->add_outgoing(txid);
    auto saved = api_.Storage().Store(sNymID, account->type(), *account);

    if (false == saved) {
        otErr << OT_METHOD << __FUNCTION__ << ": Failed to save account."
              << std::endl;

        return false;
    }

    saved = api_.Storage().Store(transaction);

    if (false == saved) {
        otErr << OT_METHOD << __FUNCTION__ << ": Failed to save transaction."
              << std::endl;

        return false;
    }

    if (recipientContactID.empty()) { return true; }

    return activity_.AddBlockchainTransaction(
        senderNymID,
        recipientContactID,
        StorageBox::OUTGOINGBLOCKCHAIN,
        transaction);
}