Skip to content

Commit

Permalink
Merge pull request #41 from fioprotocol/revert-40-opt/addaddress-1
Browse files Browse the repository at this point in the history
Revert "Optimize addaddress with new searching algorithm "
  • Loading branch information
0xCasey authored Sep 1, 2020
2 parents f25b451 + 409f937 commit 81eb24b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
28 changes: 9 additions & 19 deletions contracts/fio.address/fio.address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,28 +532,18 @@ namespace fioio {
"Invalid public address format",
ErrorChainAddressEmpty);

auto it = std::find_if(fioname_iter->addresses.begin(), fioname_iter->addresses.end(),
find_token(token));
if ((it->token_code == token) && (it->chain_code == chaincode)) {
namesbyname.modify(fioname_iter, actor, [&](struct fioname &a) {
a.addresses[it - fioname_iter->addresses.begin()].public_address = tpa->public_address;
});
wasFound = true;
} else if (it->token_code == token && it->chain_code != chaincode) {
for (auto it = fioname_iter->addresses.begin(); it != fioname_iter->addresses.end(); ++it) {
if ((it->token_code == token) && (it->chain_code == chaincode)) {
namesbyname.modify(fioname_iter, actor, [&](struct fioname &a) {
a.addresses[it - fioname_iter->addresses.begin()].public_address = tpa->public_address;
});
wasFound = true;
break;
}
for( auto it = fioname_iter->addresses.begin(); it != fioname_iter->addresses.end(); ++it ) {
if( (it->token_code == token) && (it->chain_code == chaincode) ){
namesbyname.modify(fioname_iter, actor, [&](struct fioname &a) {
a.addresses[it-fioname_iter->addresses.begin()].public_address = tpa->public_address;
});
wasFound = true;
break;
}
}

if(!wasFound){
fio_400_assert(fioname_iter->addresses.size() != MAX_SET_ADDRESSES, "token_code", tpa->token_code, "Maximum token codes mapped to single FIO Address reached. Only 200 can be mapped.",
ErrorInvalidFioNameFormat); // Don't forget to set the error amount if/when changing MAX_SET_ADDRESSES
fio_400_assert(fioname_iter->addresses.size() != 100, "token_code", tpa->token_code, "Maximum token codes mapped to single FIO Address reached. Only 100 can be mapped.",
ErrorInvalidFioNameFormat);

tempStruct.public_address = tpa->public_address;
tempStruct.token_code = tpa->token_code;
Expand Down
8 changes: 0 additions & 8 deletions contracts/fio.address/fio.address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ namespace fioio {
EOSLIB_SERIALIZE( tokenpubaddr, (token_code)(chain_code)(public_address))
};

struct find_token {
string token_code;
find_token(string token_code) : token_code(token_code) {}
bool operator () ( const tokenpubaddr& m ) const
{
return m.token_code == token_code;
}
};

struct [[eosio::action]] fioname {

Expand Down
3 changes: 2 additions & 1 deletion contracts/fio.common/fio.accounts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#pragma once

#define MAX_TRX_SIZE 8098
#define MAX_SET_ADDRESSES 200

namespace fioio {
using eosio::name;
Expand All @@ -19,6 +18,7 @@ namespace fioio {
static const name SYSTEMACCOUNT = name("eosio");
static const name ASSERTACCOUNT = name("eosio.assert");


//these are legacy system account names from EOS, we might consider blocking these.
static const name BPAYACCOUNT = name("eosio.bpay");
static const name NAMESACCOUNT = name("eosio.names");
Expand All @@ -28,6 +28,7 @@ namespace fioio {
static const name STAKEACCOUNT = name("eosio.stake");
static const name VPAYACCOUNT = name("eosio.vpay");


static const name REQOBTACCOUNT = name("fio.reqobt");
static const name FeeContract = name("fio.fee");
static const name AddressContract = name("fio.address");
Expand Down

0 comments on commit 81eb24b

Please sign in to comment.