Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemaster committed Jun 22, 2017
1 parent ecad802 commit 41f8f2d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 5 additions & 5 deletions libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ DEFINE_INTRINSIC_FUNCTION4(env,store,store,none,i32,keyptr,i32,keylen,i32,valuep
char* value = &memoryRef<char>( mem, valueptr );
string keystr( key, key+keylen);

//idump((keystr));
// if( valuelen == 8 ) idump(( *((int64_t*)value)));


const auto* obj = db.find<key_value_object,by_scope_key>( boost::make_tuple(scope, keystr) );
if( obj ) {
db.modify( *obj, [&]( auto& o ) {
o.value.resize( valuelen );
o.value.replace (0, valuelen, value);
memcpy( o.value.data(), value, valuelen );
});
} else {
db.create<key_value_object>( [&](auto& o) {
Expand Down Expand Up @@ -144,14 +143,15 @@ DEFINE_INTRINSIC_FUNCTION4(env,load,load,i32,i32,keyptr,i32,keylen,i32,valueptr,
char* key = &memoryRef<char>( mem, keyptr );
char* value = &memoryRef<char>( mem, valueptr );
string keystr( key, key+keylen);
//idump((keystr));
// idump((keystr));

const auto* obj = db.find<key_value_object,by_scope_key>( boost::make_tuple(scope, keystr) );
if( obj == nullptr ) return -1;
auto copylen = std::min<size_t>(obj->value.size(),valuelen);
// idump((copylen)(valuelen)(obj->value.size()));
if( copylen ) {
memcpy( value, obj->value.data(), copylen );
// if( copylen == 8 ) idump(( *((int64_t*)value)));
// if( copylen == 8 ) idump(( *((int64_t*)value)));
}
return copylen;
}
Expand Down Expand Up @@ -300,7 +300,7 @@ DEFINE_INTRINSIC_FUNCTION1(env,toUpper,toUpper,none,i32,charptr) {
void wasm_interface::vm_onInit()
{ try {
try {
wlog( "onInit" );
// wlog( "onInit" );
FunctionInstance* apply = asFunctionNullable(getInstanceExport(current_module,"onInit"));
if( !apply ) {
wlog( "no onInit method found" );
Expand Down
2 changes: 0 additions & 2 deletions tests/tests/block_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ R"(
(type $FUNCSIG$viiii (func (param i32 i32 i32 i32)))
(type $FUNCSIG$iii (func (param i32 i32) (result i32)))
(type $FUNCSIG$iiiii (func (param i32 i32 i32 i32) (result i32)))
(type $FUNCSIG$i (func (result i32)))
(type $FUNCSIG$iiii (func (param i32 i32 i32) (result i32)))
(import "env" "AccountName_unpack" (func $AccountName_unpack (param i32 i32)))
(import "env" "Varint_unpack" (func $Varint_unpack (param i32 i32)))
Expand Down Expand Up @@ -855,7 +854,6 @@ R"(
)
)
)";

types::SetCode handler;
Expand Down

0 comments on commit 41f8f2d

Please sign in to comment.