-
Notifications
You must be signed in to change notification settings - Fork 3.7k
support sha256 in hex as secondary key when calling get_table_rows #4908
Conversation
Update from upstream repo EOSIO/eos@master
Update from upstream repo EOSIO/eos@master
Update from upstream repo EOSIO/eos@master
Update from upstream repo EOSIO/eos@master
Update from upstream repo EOSIO/eos@master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What error do you get if you use: cleos get table account account messages --key-type i256 --index 4 -L c01b39c7a35ccc3b081a3e83d2c71fa9a767ebfeb45c69f08e17dfe3ef375a7b
@@ -28,6 +28,7 @@ | |||
|
|||
#include <fc/io/json.hpp> | |||
#include <fc/variant.hpp> | |||
#include <fc/crypto/hex.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This include file not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree ! leftover from last use of from_hex( const fc::string& hex_str, char* out_data, size_t out_data_len )
, thank you!
@@ -1029,6 +1030,14 @@ read_only::get_table_rows_result read_only::get_table_rows( const read_only::get | |||
return f128; | |||
}); | |||
} | |||
else if (p.key_type == "sha256") { | |||
return get_table_rows_by_seckey<index256_index, checksum256_type>(p, abi, [&p](const checksum256_type& v)->key256_t { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&p
not used in lambda
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, left over from earlier code I used it for logging, will remove it.
i256
assumes the string is in decimal 32 bytes numeric string not in hex , but also when I converted sha256 hex 64 bytes key to decimal 32 and used it with i256
it did not find my rows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will test it again with i256
and let you know @heifner , thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python -c 'print str(int("c01b39c7a35ccc3b081a3e83d2c71fa9a767ebfeb45c69f08e17dfe3ef375a7b", 16))'
86892170580511395102392104225515491945535356631148603271263139179137605261947
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heifner , I will use that decimal again to test if i256
works .
@heifner not sure if is a issue, or a miss config from my side, but if you have a sec, please check https://eosio.stackexchange.com/questions/3219/how-to-properly-use-cleos-get-table-with-key-type-sha256-secondary-index-fa |
@venediktov is this working for you on 1.4.+ ? could you provide me with an example using get table? thanks |
@gustavomick I had multiple examples that worked unfortunately due to NDA with a client I can't share it here , we only used 1.3 though how do you initialize your |
@gustavomick , I found your issue please see a change needed for your checksum256_to_sha256
I justs tested it worked with this command
|
This is related to pull request #4053
We have a contract similar to
dice.cpp
where table has non-unique indexchecksum256 uuid
column andwe need to retrieve all entries matching that fields as it serves a UUID of a handshake session .
@taokayan , @heifner - Please let me know if you think it's valid case to pass
sha256
hex string toget_table_rows
Use case
cleos get table account account messages --key-type sha256 --index 4 -L c01b39c7a35ccc3b081a3e83d2c71fa9a767ebfeb45c69f08e17dfe3ef375a7b