10
votes
Accepted
Are Tables/DBs stored in RAM and held by multiple block producers?
EOSIO keeps the state in RAM. All the data for the contracts and transactions are held in RAM.
All block producers (BP) process the transactions and keep an updated state of the database in RAM.
...
10
votes
Accepted
How to use two secondary keys as a filter? (WHERE f1 AND f2)
So, for this scenario we can create another index that concatenates both indexes and look for it. As an example, let's see a scenario where we can invite accounts to a group and each invitation has an ...
9
votes
Accepted
What are naming rules for actions, tables and contracts?
Action names, table names, index names, account names, and everything else you use N(foo), "foo"_n, or eosio::name("foo") for, have these rules. A contract belongs to an account.
12 characters max
...
9
votes
How to use checksum256 secondary index to get table rows
Some further explanation of how the value to pass via cleos was derived. As already mentioned in the original post, this all revolves around endianness. For some reason the checksum256 value is ...
8
votes
Accepted
Delete all multi_index records without iterator?
After I didn't find any other solution, I ended up with a sequential workaround which will delete all records by time.
Disclaimer: Be sure to block all other actions that would rely on the index, ...
tmm♦
- 2,114
7
votes
HOWTO: auto increment primary key?
Have a look to available_primary_key in the EOS documentation, multi indexes do support auto increment keys.
5
votes
Accepted
Can an action in a smart contract concurrently executed?
If I understood everything correctly:
A transaction stores multiple actions. Transactions are stored in blocks. Every block producer has its turn (approx. 0.5 sec for this DPOS) to create a block and ...
tmm♦
- 2,114
5
votes
Accepted
Error 3160003: Invalid table iterator
If your table doesn't have any elements, then it will throw this error.
Whenever you use the find command, always check afterwards that an element was found:
auto element = candidates.find( id );
if(...
5
votes
Accepted
Multiple parameters for search
For "multi-index" searches I use one index to perform the search on my primary, then simply loop through the iterator until I either find the item I'm looking for with the matching secondary key.
...
5
votes
Accepted
Is it possible to use a type other than uint64_t for a table primary key?
According to the official documentation you can find here:
They are multi index tables because they support using multiple indexes on the data, the primary index type must be uint64_t and must be ...
4
votes
Accepted
Purpose of multi_index scope
UPDATE: It seems Block.one does not plan to implement the functionalities necessary for scopes to actually make any difference in performance, which renders scopes useful only for separating your data ...
4
votes
Is there a function to return the size of a multi_index table?
Agree no size is maintained by EOS implementation , the iterators are not random access , so if size state not maintained (which would be best performance compared to calculating size on the fly when ...
4
votes
How to allow duplicates in an eosio::multi_index object?
I guess your problem might be that you are saving the primary key as uint32_t but it has to be a uint64_t. Because it might be that if you try to save the id (0x00000000) it will cut the last 32 bits ...
tmm♦
- 2,114
4
votes
Accepted
How to create composite primary key?
the problem is that the primary key index cannot be 128 bits long. it must be 64 bits. but other indexes can be 128 bits
so my solution was to implement an auto-generated monotonic primary key and ...
3
votes
How to erase data with secondary index?
From your code I assume you want to delete all entries on the table that have less than 100 exp.
The biggest problem I see here is not limiting how many items you delete from the table. As in this ...
3
votes
Accepted
Trying to pass a sha256 hash to my contract and store it
Figured it out, trick was to use a combination of checksum256 and key256.
Used the dice contract as an example:
struct offer {
uint64_t id;
account_name owner;
asset ...
3
votes
Accepted
Using name as secondary index
This is the functionality that the multi index was based around.
To get the name, simple add .value to your key on return:
uint64_t primary_key() const { return key.value;} // key.VALUE
In the ...
3
votes
Accepted
What is the meaning of "scope" in a Smart Contract?
EOSIO organizes data in the fashion described in the graphic below.
The scope usually refers to the account in relation to which the data is stored. So eosio.token stores each account's token balance ...
3
votes
How to upgrade a multi_index table in a smart contract
If you don't care about the data from old_table:
Erase all records from old_table
Deploy NEWCONTRACT with modified old_table
If you want to persist the data from old_table:
Define the new and old ...
2
votes
Are Tables/DBs stored in RAM and held by multiple block producers?
EOS.IO stores indexed state in a custom-written database engine called Chainbase.
This database is optimised for high performance when the entire database fits into memory, and it's expected that ...
2
votes
Can an arbitrary account add to a table (eosio::multi_index) belonging to a particular account?
Multi-index is the only option.
An arbitrary account can modify the table through an action sent to the contract for the particular account.
2
votes
How to understand RAM and log storage from the view of Smart Contract?
For example, if I launched that tic-tac-toe demo to the mainnet, where is its Multi-Index table data stored? Does RAM always caches the current state of the table?
The Multi-Index struct content is ...
2
votes
How to set the “ —key-type” parameter and “--index” parameter of v1/chain/get_table_rows function?
i have solved this question.
I execute the command ”./cleos -u "http://dev.cryptolions.io:38888" get table xun xun cates --key-type i64 --index 2“
then i get the socket data packets use wireshark.
...
2
votes
How can I know if I pay ram for a row in a table?
you can get the ram consume before version 1.2.3 like this:
void apply_context::update_db_usage( const account_name& payer, int64_t delta ) {
if( delta > 0 ) {
if( !(privileged || ...
2
votes
Accepted
Same name table of different contracts got merged
As per this description i can say that at the time of deployment called A you have not added that table abi that's why you are not able to call getTableRows() but actually the table actions have ...
2
votes
Multi-index storing complex types
The EOS multi-index table is based on Boost multi-index containers. From this question and this question it doesn't seem possible to store classes directly as fields, but it seems possible to manage ...
2
votes
Multi_index query with new CDT
You can call name.value to get a uin64_t representation of the name. In your find call, you want to do auto iterator = host_games.find(host.value); to match the uint64_t type that your secondary ...
2
votes
Multi_index query with new CDT
To anyone having the same issues. I managed to fix it like this:
struct [[eosio::table]] game
{
uint64_t id; //auto increment
name host;
name guest= name("none");
name player_to_play =...
2
votes
Accepted
How does "tablename"_n differ to N(tablename) when defining a multi_index?
The N macro was replaced with the _n operator. It is one of the breaking changes introduced recently. Here is the complete list, https://github.com/EOSIO/eosio.cdt/blob/master/README.md
Removal of ...
2
votes
Iterating through secondary indices
Ok I found the problem, I'll put it here so the next guy won't do the same.
I was zeroing the act value inside the loop, so somehow the iterator kept hitting the same row with a value < 0. The ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
multi-index × 99smart-contract × 47
table × 24
eosio.cdt × 8
eosjs × 6
get-table × 6
ram × 5
primarykey × 5
index × 5
nodeos × 4
eosio-code × 4
rpc × 4
cleos × 3
action × 3
c++ × 3
dapp × 3
database × 3
data-storage × 3
javascript × 2
contract-development × 2
chainbase × 2
string × 2
persistence-api × 2
persistence × 2
accounts × 1