Skip to content

Commit

Permalink
Merge pull request #309 from eosnetworkfoundation/remove_eosio_name_a…
Browse files Browse the repository at this point in the history
…ccount_table

remove eosio account name & secondary index from EVM account table
  • Loading branch information
spoonincode committed Feb 8, 2023
2 parents f02ae74 + fa75b56 commit 5d9a9cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
8 changes: 1 addition & 7 deletions contract/include/evm_runtime/tables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,11 @@ struct [[eosio::table]] [[eosio::contract("evm_contract")]] account {
bytes eth_address;
uint64_t nonce;
bytes balance;
name eos_account;
bytes code;
bytes code_hash;

uint64_t primary_key()const { return id; }

uint64_t by_eos_account()const {
return eos_account.value;
}

checksum256 by_eth_address()const {
return make_key(eth_address);
}
Expand All @@ -43,12 +38,11 @@ struct [[eosio::table]] [[eosio::contract("evm_contract")]] account {
return res;
}

EOSLIB_SERIALIZE(account, (id)(eth_address)(nonce)(balance)(eos_account)(code)(code_hash));
EOSLIB_SERIALIZE(account, (id)(eth_address)(nonce)(balance)(code)(code_hash));
};

typedef multi_index< "account"_n, account,
indexed_by<"by.address"_n, const_mem_fun<account, checksum256, &account::by_eth_address>>,
indexed_by<"by.account"_n, const_mem_fun<account, uint64_t, &account::by_eos_account>>,
indexed_by<"by.codehash"_n, const_mem_fun<account, checksum256, &account::by_code_hash>>
> account_table;

Expand Down
16 changes: 3 additions & 13 deletions contract/tests/evm_runtime_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ struct account {
bytes eth_address;
uint64_t nonce;
bytes balance;
name eos_account;
bytes code;
bytes code_hash;

Expand All @@ -250,13 +249,6 @@ struct account {
}
};

struct by_account {
typedef index64_object index_object;
static name index_name() {
return account::index_name("by.account"_n);
}
};

struct by_codehash {
typedef index256_object index_object;
static name index_name() {
Expand All @@ -280,13 +272,11 @@ struct account {
static name index_name(const name& n) {
uint64_t index_table_name = table_name().to_uint64_t() & 0xFFFFFFFFFFFFFFF0ULL;

//0=>by.address, 1=>by.account, 2=>by.codehash
//0=>by.address, 1=>by.codehash
if( n == "by.address"_n ) {
return name{index_table_name | 0};
} else if( n == "by.account"_n ) {
return name{index_table_name | 1};
} else if( n == "by.codehash"_n ) {
return name{index_table_name | 2};
return name{index_table_name | 1};
}

dlog("index name not found: ${a}", ("a",n.to_string()));
Expand Down Expand Up @@ -320,7 +310,7 @@ struct account {
}

};
FC_REFLECT(account, (id)(eth_address)(nonce)(balance)(eos_account)(code)(code_hash));
FC_REFLECT(account, (id)(eth_address)(nonce)(balance)(code)(code_hash));

struct storage {
uint64_t id;
Expand Down

0 comments on commit 5d9a9cf

Please sign in to comment.