github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/v8/lib/fake_blockchain.cc (about) 1 // Copyright (C) 2017 go-nebulas authors 2 // 3 // This file is part of the go-nebulas library. 4 // 5 // the go-nebulas library is free software: you can redistribute it and/or 6 // modify it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // the go-nebulas library is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with the go-nebulas library. If not, see 17 // <http://www.gnu.org/licenses/>. 18 // 19 20 #include "fake_blockchain.h" 21 22 #include <stdio.h> 23 #include <stdlib.h> 24 #include <string> 25 26 #include <string.h> 27 #include "nvm_error.h" 28 29 using namespace std; 30 31 char *GetTxByHash(void *handler, const char *hash, size_t *gasCnt) { 32 *gasCnt = 1000; 33 34 char *ret = NULL; 35 string value = "{\"hash\":\"5e6d587f26121f96a07cf4b8b569aac1\",\"from\":" 36 "\"70e30fcae5e7f4b2460faaa9e5b1bd912332ebb5\",\"to\":" 37 "\"70e30fcae5e7f4b2460faaa9e5b1bd912332ebb5\",\"value\":1," 38 "\"nonce\":4}"; 39 ret = (char *)calloc(value.length() + 1, sizeof(char)); 40 strncpy(ret, value.c_str(), value.length()); 41 return ret; 42 } 43 44 int GetAccountState(void *handler, const char *address, size_t *gasCnt, char **result, char **info) { 45 *gasCnt = 1000; 46 47 string value = "{\"value\":1,\"nonce\":4}"; 48 *result = (char *)calloc(value.length() + 1, sizeof(char)); 49 strncpy(*result, value.c_str(), value.length()); 50 return NVM_SUCCESS; 51 } 52 53 int Transfer(void *handler, const char *to, const char *value, size_t *gasCnt) { 54 *gasCnt = 2000; 55 return NVM_SUCCESS; 56 } 57 58 int VerifyAddress(void *handler, const char *address, size_t *gasCnt) { 59 *gasCnt = 100; 60 return NVM_SUCCESS; 61 } 62 63 int GetPreBlockHash(void *handler, unsigned long long offset, size_t *gasCnt, char **result, char **info) { 64 *gasCnt = 1000; 65 return NVM_SUCCESS; 66 } 67 68 int GetPreBlockSeed(void *handler, unsigned long long offset, size_t *gasCnt, char **result, char **info) { 69 *gasCnt = 1000; 70 return NVM_SUCCESS; 71 } 72 73 int GetLatestNebulasRank(void *handler, const char *address, size_t *gasCnt, char **result, char **info) { 74 *gasCnt = 20000; 75 return NVM_SUCCESS; 76 } 77 78 int GetLatestNebulasRankSummary(void *handler, size_t *gasCnt, char **result, char **info) { 79 *gasCnt = 20000; 80 return NVM_SUCCESS; 81 } 82