├── Chain ├── .gitignore ├── CMakeLists.txt ├── Main.cpp └── libraries │ ├── UnitTest++ │ ├── AssertException.cpp │ ├── Checks.cpp │ ├── CompositeTestReporter.cpp │ ├── CurrentTest.cpp │ ├── DeferredTestReporter.cpp │ ├── DeferredTestResult.cpp │ ├── Makefile.am │ ├── MemoryOutStream.cpp │ ├── Posix │ │ ├── SignalTranslator.cpp │ │ └── TimeHelpers.cpp │ ├── ReportAssert.cpp │ ├── RequiredCheckException.cpp │ ├── RequiredCheckTestReporter.cpp │ ├── Test.cpp │ ├── TestDetails.cpp │ ├── TestList.cpp │ ├── TestReporter.cpp │ ├── TestReporterStdout.cpp │ ├── TestResults.cpp │ ├── TestRunner.cpp │ ├── ThrowingTestReporter.cpp │ ├── TimeConstraint.cpp │ ├── Win32 │ │ └── TimeHelpers.cpp │ └── XmlTestReporter.cpp │ ├── api │ ├── ConversionFunctions.cpp │ └── GlobalApiLogger.cpp │ ├── blockchain │ ├── AccountEntry.cpp │ ├── AccountOperations.cpp │ ├── Address.cpp │ ├── Asset.cpp │ ├── AssetEntry.cpp │ ├── AssetOperations.cpp │ ├── BalanceEntry.cpp │ ├── BalanceOperations.cpp │ ├── Block.cpp │ ├── ChainDatabase.cpp │ ├── ChainInterface.cpp │ ├── ContractEntry.cpp │ ├── ContractOperations.cpp │ ├── EventOperations.cpp │ ├── ExtendedAddress.cpp │ ├── ForkBlocks.cpp │ ├── GenesisJson.cpp │ ├── GenesisJson_test.cpp │ ├── ImessageOperations.cpp │ ├── Operations.cpp │ ├── PendingChainState.cpp │ ├── PropertyEntry.cpp │ ├── PtsAddress.cpp │ ├── SlateEntry.cpp │ ├── SlateOperations.cpp │ ├── SlotEntry.cpp │ ├── StorageOperations.cpp │ ├── StorageTypes.cpp │ ├── Time.cpp │ ├── Transaction.cpp │ ├── TransactionCreationState.cpp │ ├── TransactionEntry.cpp │ ├── TransactionEvaluationState.cpp │ ├── TransactionOperations.cpp │ ├── Types.cpp │ └── WithdrawTypes.cpp │ ├── cli │ ├── Cli.cpp │ ├── Pretty.cpp │ └── PrintResult.cpp │ ├── client │ ├── ApiLogger.cpp │ ├── BlockchainApi.cpp │ ├── Client.cpp │ ├── ContractApi.cpp │ ├── DebugApi.cpp │ ├── DelegateApi.cpp │ ├── GeneralApi.cpp │ ├── Messages.cpp │ ├── NetworkApi.cpp │ ├── Notifier.cpp │ ├── SandboxContractApi.cpp │ ├── ScriptApi.cpp │ └── WalletApi.cpp │ ├── db │ └── UpgradeLeveldb.cpp │ ├── glua │ ├── README.md │ ├── glua_api_types.cpp │ ├── glua_astparser.cpp │ ├── glua_debug_file.cpp │ ├── glua_decompile.cpp │ ├── glua_disassemble.cpp │ ├── glua_loader.cpp │ ├── glua_lutil.cpp │ ├── glua_proto_info.cpp │ ├── glua_state_scope.cpp │ ├── glua_statement.cpp │ ├── glua_structs.cpp │ ├── glua_tokenparser.cpp │ ├── glua_vm.cpp │ ├── init_debugger_info.db │ ├── language_server.cpp │ ├── language_server.md │ ├── lapi.cpp │ ├── lauxlib.cpp │ ├── lbaselib.cpp │ ├── lbitlib.cpp │ ├── lcode.cpp │ ├── lcompile.cpp │ ├── lcorolib.cpp │ ├── lctype.cpp │ ├── ldblib.cpp │ ├── ldebug.cpp │ ├── ldo.cpp │ ├── ldump.cpp │ ├── lfunc.cpp │ ├── lgc.cpp │ ├── lhashmap.cpp │ ├── lhttplib.cpp │ ├── linit.cpp │ ├── liolib.cpp │ ├── ljsonlib.cpp │ ├── ljsonrpclib.cpp │ ├── llex.cpp │ ├── lmathlib.cpp │ ├── lmem.cpp │ ├── lnetlib.cpp │ ├── loadlib.cpp │ ├── lobject.cpp │ ├── lopcodes.cpp │ ├── loslib.cpp │ ├── lparser.cpp │ ├── lparsercombinator.cpp │ ├── lprefix.cpp │ ├── lremote_debugger.cpp │ ├── lrepl.cpp │ ├── lstate.cpp │ ├── lstring.cpp │ ├── lstrlib.cpp │ ├── ltable.cpp │ ├── ltablib.cpp │ ├── lthinkyounglib.cpp │ ├── ltimelib.cpp │ ├── ltm.cpp │ ├── ltype_checker_type_info.cpp │ ├── ltypechecker.cpp │ ├── lua.cpp │ ├── luac.cpp │ ├── lundump.cpp │ ├── lutf8lib.cpp │ ├── lvm.cpp │ ├── lzio.cpp │ ├── single_glua_src │ │ ├── cdemo1.cpp │ │ ├── main.cpp │ │ ├── thinkyoung_lua_api.demo.cpp │ │ └── thinkyoung_lua_api.demo.h │ ├── tests_lua │ │ ├── .gitignore │ │ ├── error_syntax.lua │ │ ├── test1.lua │ │ ├── test2.lua │ │ ├── test3.lua │ │ ├── test4.lua │ │ ├── test_c_function.lua │ │ ├── test_c_module_inject.lua │ │ ├── test_compile_error.lua │ │ ├── test_contract_transfer.lua │ │ ├── test_debugger.lua │ │ ├── test_error.lua │ │ ├── test_error_syntax.lua │ │ ├── test_error_use_api.lua │ │ ├── test_exit_contract.lua │ │ ├── test_for_loop_goto.lua │ │ ├── test_get_global_table.lua │ │ ├── test_import_not_found.lua │ │ ├── test_load_contract.lua │ │ ├── test_no_return_contract.lua │ │ ├── test_stop_vm.lua │ │ ├── test_too_many_localvars.lua │ │ ├── test_tostring.lua │ │ ├── test_upval.lua │ │ ├── test_use_error_function.lua │ │ ├── test_without_init.lua │ │ ├── test_wrong_contract.lua │ │ └── 测试中文.lua │ ├── tests_typed │ │ ├── bin_and_un_op_type.lua │ │ ├── call_without_brackets.lua │ │ ├── call_without_brackets_error.lua │ │ ├── correct_nested_table.glua │ │ ├── declare_with_type.lua │ │ ├── duplicate_return.glua │ │ ├── empty_correct_contract.glua │ │ ├── full_correct_typed.glua │ │ ├── full_demo.lua │ │ ├── function_type_and_call.lua │ │ ├── function_type_declare.lua │ │ ├── generic_type.lua │ │ ├── let_var.lua │ │ ├── nested_function_define.lua │ │ ├── nested_record.lua │ │ ├── record_table_parse.lua │ │ ├── return_union_type.lua │ │ ├── self_type.lua │ │ ├── simple_record.lua │ │ ├── test_api_return.glua │ │ ├── test_array_fetch.glua │ │ ├── test_break.glua │ │ ├── test_calculate.glua │ │ ├── test_call_contract_it_self.glua │ │ ├── test_change_contract_id.glua │ │ ├── test_contract_return_wrong_type.glua │ │ ├── test_contract_storage_property_type.glua │ │ ├── test_control_scopes.glua │ │ ├── test_correct_contract.glua │ │ ├── test_define_contract_api_using_dot.glua │ │ ├── test_define_global_in_contract.glua │ │ ├── test_deny_call_special_apis.glua │ │ ├── test_echo_http_server.lua │ │ ├── test_emit_events.glua │ │ ├── test_for_variable1.glua │ │ ├── test_function_type_up.glua │ │ ├── test_goto.glua │ │ ├── test_if_stat.glua │ │ ├── test_import_contract.lua │ │ ├── test_import_correct_contract.glua │ │ ├── test_inner_module_type_info.glua │ │ ├── test_int_number_parse.glua │ │ ├── test_market.lua │ │ ├── test_missing_end.glua │ │ ├── test_missing_record_colon.glua │ │ ├── test_multi_lines_lambda.glua │ │ ├── test_multiline_comment_and_string.glua │ │ ├── test_new_array_and_map_type.glua │ │ ├── test_over_number_limit.glua │ │ ├── test_pairs.glua │ │ ├── test_quick_storage_change.glua │ │ ├── test_record_constructor_and_call_as_func.glua │ │ ├── test_storage.glua │ │ ├── test_storage_not_init_contract.glua │ │ ├── test_storage_performance.glua │ │ ├── test_stream_type.glua │ │ ├── test_table_module.glua │ │ ├── test_table_property_function_call.glua │ │ ├── test_tojsonstring.glua │ │ ├── test_typed_exit_contract.glua │ │ ├── test_typed_too_many_locals.glua │ │ ├── test_use_keyword_as_varname.glua │ │ ├── test_use_not_init_variable.glua │ │ ├── test_var_and_type_namespace.glua │ │ ├── test_wrong_new_array_and_map_type.glua │ │ ├── test_wrong_syntax_structure1.glua │ │ ├── type_parse.lua │ │ ├── typedef_and_partial.lua │ │ ├── un_op_run_error1.lua │ │ ├── un_op_run_error2.lua │ │ ├── unicode.lua │ │ ├── variable_scope.lua │ │ └── visit_prop.lua │ ├── thinkyoung_lua_api.cpp │ ├── thinkyoung_lua_lib.cpp │ └── thinkyoung_lua_modules │ │ ├── .gitignore │ │ ├── thinkyoung_contract_contract_transfer_demo.lua │ │ └── thinkyoung_contract_demo1.lua │ ├── include │ ├── UnitTest++ │ │ ├── AssertException.h │ │ ├── CheckMacros.h │ │ ├── Checks.h │ │ ├── CompositeTestReporter.h │ │ ├── Config.h │ │ ├── CurrentTest.h │ │ ├── DeferredTestReporter.h │ │ ├── DeferredTestResult.h │ │ ├── ExceptionMacros.h │ │ ├── ExecuteTest.h │ │ ├── HelperMacros.h │ │ ├── MemoryOutStream.h │ │ ├── Posix │ │ │ ├── SignalTranslator.h │ │ │ └── TimeHelpers.h │ │ ├── ReportAssert.h │ │ ├── ReportAssertImpl.h │ │ ├── RequireMacros.h │ │ ├── RequiredCheckException.h │ │ ├── RequiredCheckTestReporter.h │ │ ├── Test.h │ │ ├── TestDetails.h │ │ ├── TestList.h │ │ ├── TestMacros.h │ │ ├── TestReporter.h │ │ ├── TestReporterStdout.h │ │ ├── TestResults.h │ │ ├── TestRunner.h │ │ ├── TestSuite.h │ │ ├── ThrowingTestReporter.h │ │ ├── TimeConstraint.h │ │ ├── TimeHelpers.h │ │ ├── UnitTest++.h │ │ ├── UnitTestPP.h │ │ ├── Win32 │ │ │ └── TimeHelpers.h │ │ └── XmlTestReporter.h │ ├── api │ │ ├── ApiMetadata.hpp │ │ ├── CommonApi.hpp │ │ ├── ConversionFunctions.hpp │ │ └── GlobalApiLogger.hpp │ ├── blockchain │ │ ├── AccountEntry.hpp │ │ ├── AccountOperations.hpp │ │ ├── Address.hpp │ │ ├── Asset.hpp │ │ ├── AssetEntry.hpp │ │ ├── AssetOperations.hpp │ │ ├── BalanceEntry.hpp │ │ ├── BalanceOperations.hpp │ │ ├── Block.hpp │ │ ├── BlockEntry.hpp │ │ ├── ChainDatabase.hpp │ │ ├── ChainDatabaseImpl.hpp │ │ ├── ChainInterface.hpp │ │ ├── Checkpoints.hpp │ │ ├── Condition.hpp │ │ ├── Config.hpp │ │ ├── ContractEntry.hpp │ │ ├── ContractOperations.hpp │ │ ├── DelegateConfig.hpp │ │ ├── EventOperations.hpp │ │ ├── Exceptions.hpp │ │ ├── ExtendedAddress.hpp │ │ ├── ForkBlocks.hpp │ │ ├── GenesisJson.hpp │ │ ├── GenesisState.hpp │ │ ├── GluaChainApi.hpp │ │ ├── ImessageOperations.hpp │ │ ├── OperationFactory.hpp │ │ ├── Operations.hpp │ │ ├── PendingChainState.hpp │ │ ├── PropertyEntry.hpp │ │ ├── PtsAddress.hpp │ │ ├── SlateEntry.hpp │ │ ├── SlateOperations.hpp │ │ ├── SlotEntry.hpp │ │ ├── StorageOperations.hpp │ │ ├── StorageTypes.hpp │ │ ├── Time.hpp │ │ ├── Transaction.hpp │ │ ├── TransactionCreationState.hpp │ │ ├── TransactionEntry.hpp │ │ ├── TransactionEvaluationState.hpp │ │ ├── TransactionOperations.hpp │ │ ├── Types.hpp │ │ ├── WithdrawTypes.hpp │ │ └── api_extern.hpp │ ├── cli │ │ ├── Cli.hpp │ │ ├── Pretty.hpp │ │ ├── PrintResult.hpp │ │ └── locale.hpp │ ├── client │ │ ├── ApiLogger.hpp │ │ ├── Client.hpp │ │ ├── ClientImpl.hpp │ │ ├── Messages.hpp │ │ ├── Notifier.hpp │ │ ├── SeedNodes.hpp │ │ └── build_info.hpp.in │ ├── db │ │ ├── CachedLevelMap.hpp │ │ ├── Exception.hpp │ │ ├── FastLevelMap.hpp │ │ ├── FsHashMap.hpp │ │ ├── Fwd.hpp │ │ ├── LevelMap.hpp │ │ ├── LevelPodMap.hpp │ │ └── UpgradeLeveldb.hpp │ ├── glua │ │ ├── exceptions.h │ │ ├── glua_api_types.h │ │ ├── glua_astparser.h │ │ ├── glua_common.h │ │ ├── glua_compat.h │ │ ├── glua_debug_file.h │ │ ├── glua_decompile.h │ │ ├── glua_disassemble.h │ │ ├── glua_loader.h │ │ ├── glua_lutil.h │ │ ├── glua_parser.h │ │ ├── glua_proto_info.h │ │ ├── glua_statement.h │ │ ├── glua_structs.h │ │ ├── glua_tokenparser.h │ │ ├── glua_vm.h │ │ ├── lapi.h │ │ ├── lauxlib.h │ │ ├── lcode.h │ │ ├── lcompile.h │ │ ├── lctype.h │ │ ├── ldebug.h │ │ ├── ldo.h │ │ ├── lfunc.h │ │ ├── lgc.h │ │ ├── lhashmap.h │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmem.h │ │ ├── lnetlib.h │ │ ├── lobject.h │ │ ├── lopcodes.h │ │ ├── lparser.h │ │ ├── lparsercombinator.h │ │ ├── lprefix.h │ │ ├── lremote_debugger.h │ │ ├── lrepl.h │ │ ├── lstate.h │ │ ├── lstring.h │ │ ├── ltable.h │ │ ├── lthinkyounglib.h │ │ ├── ltm.h │ │ ├── ltype_checker_type_info.h │ │ ├── ltypechecker.h │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.h │ │ ├── lvm.h │ │ ├── lzio.h │ │ ├── thinkyoung_lua_api.h │ │ └── thinkyoung_lua_lib.h │ ├── net │ │ ├── ChainConnection.hpp │ │ ├── ChainDownloader.hpp │ │ ├── ChainMessages.hpp │ │ ├── ChainServer.hpp │ │ ├── ChainServerCommands.hpp │ │ ├── Config.hpp │ │ ├── Connection.hpp │ │ ├── CoreMessages.hpp │ │ ├── Exceptions.hpp │ │ ├── Message.hpp │ │ ├── MessageOrientedConnection.hpp │ │ ├── Node.hpp │ │ ├── PeerConnection.hpp │ │ ├── PeerDatabase.hpp │ │ ├── StcpSocket.hpp │ │ └── Upnp.hpp │ ├── rpc │ │ ├── Exceptions.hpp │ │ ├── RpcClient.hpp │ │ ├── RpcClientApi.hpp │ │ └── RpcServer.hpp │ ├── rpc_stubs │ │ ├── CommonApiClient.hpp │ │ ├── CommonApiOverrides.ipp │ │ ├── CommonApiRpcClient.hpp │ │ └── CommonApiRpcServer.hpp │ ├── utilities │ │ ├── CommonApi.hpp │ │ ├── GitRevision.hpp │ │ ├── KeyConversion.hpp │ │ ├── PaddingOstream.hpp │ │ ├── StringEscape.hpp │ │ ├── ThreadPool.hpp │ │ └── Words.hpp │ └── wallet │ │ ├── Config.hpp │ │ ├── Exceptions.hpp │ │ ├── Pretty.hpp │ │ ├── TransactionBuilder.hpp │ │ ├── Url.hpp │ │ ├── Wallet.hpp │ │ ├── WalletDb.hpp │ │ ├── WalletEntrys.hpp │ │ ├── WalletImpl.hpp │ │ └── url.hpp.in │ ├── net │ ├── ChainDownloader.cpp │ ├── ChainServer.cpp │ ├── CoreMessages.cpp │ ├── MessageOrientedConnection.cpp │ ├── Node.cpp │ ├── PeerConnection.cpp │ ├── PeerDatabase.cpp │ ├── StcpSocket.cpp │ └── Upnp.cpp │ ├── rpc │ ├── RpcClient.cpp │ └── RpcServer.cpp │ ├── rpc_stubs │ ├── CommonApiClient.cpp │ ├── CommonApiRpcClient.cpp │ └── CommonApiRpcServer.cpp │ ├── utilities │ ├── CommonApi.cpp │ ├── GitRevision.cpp │ ├── KeyConversion.cpp │ ├── StringEscape.cpp │ └── Words.cpp │ └── wallet │ ├── Login.cpp │ ├── TransactionBuilder.cpp │ ├── TransactionLedger.cpp │ ├── TransactionLedgerExperimental.cpp │ ├── Wallet.cpp │ ├── WalletDb.cpp │ └── WalletEntrys.cpp ├── LICENSE ├── README.md ├── build_centos.sh ├── build_mac.sh ├── build_ubuntu.sh ├── include ├── .gitkeep ├── fc │ ├── actor.hpp │ ├── aligned.hpp │ ├── any.hpp │ ├── api.hpp │ ├── array.hpp │ ├── asio.hpp │ ├── bitutil.hpp │ ├── bloom_filter.hpp │ ├── compress │ │ ├── smaz.hpp │ │ └── zlib.hpp │ ├── container │ │ ├── deque.hpp │ │ ├── deque_fwd.hpp │ │ ├── flat.hpp │ │ └── flat_fwd.hpp │ ├── crypto │ │ ├── aes.hpp │ │ ├── base32.hpp │ │ ├── base36.hpp │ │ ├── base58.hpp │ │ ├── base64.hpp │ │ ├── bigint.hpp │ │ ├── blowfish.hpp │ │ ├── city.hpp │ │ ├── dh.hpp │ │ ├── digest.hpp │ │ ├── elliptic.hpp │ │ ├── hex.hpp │ │ ├── hmac.hpp │ │ ├── openssl.hpp │ │ ├── pke.hpp │ │ ├── rand.hpp │ │ ├── ripemd160.hpp │ │ ├── sha1.hpp │ │ ├── sha224.hpp │ │ ├── sha256.hpp │ │ └── sha512.hpp │ ├── exception │ │ └── exception.hpp │ ├── filesystem.hpp │ ├── fwd.hpp │ ├── fwd_impl.hpp │ ├── git_revision.hpp │ ├── interprocess │ │ ├── file_mapping.hpp │ │ ├── iprocess.hpp │ │ ├── mmap_struct.hpp │ │ ├── process.hpp │ │ └── signals.hpp │ ├── io │ │ ├── buffered_iostream.hpp │ │ ├── console.hpp │ │ ├── datastream.hpp │ │ ├── datastream_back.hpp │ │ ├── enum_type.hpp │ │ ├── fstream.hpp │ │ ├── iobuffer.hpp │ │ ├── iostream.hpp │ │ ├── json.hpp │ │ ├── json_relaxed.hpp │ │ ├── raw.hpp │ │ ├── raw_fwd.hpp │ │ ├── raw_unpack_file.hpp │ │ ├── raw_variant.hpp │ │ ├── sstream.hpp │ │ ├── stdio.hpp │ │ └── varint.hpp │ ├── log │ │ ├── appender.hpp │ │ ├── console_appender.hpp │ │ ├── file_appender.hpp │ │ ├── gelf_appender.hpp │ │ ├── log_message.hpp │ │ ├── logger.hpp │ │ └── logger_config.hpp │ ├── make_fused.hpp │ ├── network │ │ ├── gntp.hpp │ │ ├── http │ │ │ ├── connection.hpp │ │ │ ├── server.hpp │ │ │ └── websocket.hpp │ │ ├── ip.hpp │ │ ├── ntp.hpp │ │ ├── rate_limiting.hpp │ │ ├── resolve.hpp │ │ ├── tcp_socket.hpp │ │ ├── tcp_socket_io_hooks.hpp │ │ ├── udp_socket.hpp │ │ ├── udt_socket.hpp │ │ └── url.hpp │ ├── noncopyable.hpp │ ├── optional.hpp │ ├── platform_independence.hpp │ ├── real128.hpp │ ├── reflect │ │ ├── reflect.hpp │ │ ├── typename.hpp │ │ └── variant.hpp │ ├── rpc │ │ ├── api_connection.hpp │ │ ├── cli.hpp │ │ ├── http_api.hpp │ │ ├── json_connection.hpp │ │ ├── state.hpp │ │ ├── variant_connection.hpp │ │ ├── variant_stream.hpp │ │ └── websocket_api.hpp │ ├── safe.hpp │ ├── shared_ptr.hpp │ ├── signal.hpp │ ├── signals.hpp │ ├── smart_ref_fwd.hpp │ ├── smart_ref_impl.hpp │ ├── ssh │ │ ├── client.hpp │ │ ├── error.hpp │ │ └── process.hpp │ ├── static_variant.hpp │ ├── string.hpp │ ├── thread │ │ ├── future.hpp │ │ ├── mutex.hpp │ │ ├── non_preemptable_scope_check.hpp │ │ ├── priority.hpp │ │ ├── scoped_lock.hpp │ │ ├── spin_lock.hpp │ │ ├── spin_yield_lock.hpp │ │ ├── task.hpp │ │ ├── thread.hpp │ │ ├── thread_specific.hpp │ │ ├── unique_lock.hpp │ │ └── wait_condition.hpp │ ├── time.hpp │ ├── tuple.hpp │ ├── uint128.hpp │ ├── unique_ptr.hpp │ ├── utf8.hpp │ ├── utility.hpp │ ├── variant.hpp │ ├── variant_object.hpp │ ├── vector.hpp │ ├── vector_fwd.hpp │ └── wait_any.hpp ├── leveldb │ ├── c.h │ ├── cache.h │ ├── comparator.h │ ├── db.h │ ├── dumpfile.h │ ├── env.h │ ├── filter_policy.h │ ├── iterator.h │ ├── options.h │ ├── slice.h │ ├── status.h │ ├── table.h │ ├── table_builder.h │ └── write_batch.h └── miniupnpc │ ├── CMakeLists.txt │ ├── Changelog.txt │ ├── LICENSE │ ├── MANIFEST.in │ ├── Makefile │ ├── Makefile.mingw │ ├── README │ ├── VERSION │ ├── bsdqueue.h │ ├── codelength.h │ ├── connecthostport.c │ ├── connecthostport.h │ ├── declspec.h │ ├── external-ip.sh │ ├── igd_desc_parse.c │ ├── igd_desc_parse.h │ ├── mingw32make.bat │ ├── minihttptestserver.c │ ├── minisoap.c │ ├── minisoap.h │ ├── minissdpc.c │ ├── minissdpc.h │ ├── miniupnpc.c │ ├── miniupnpc.def │ ├── miniupnpc.h │ ├── miniupnpcmodule.c │ ├── miniupnpcstrings.h.cmake │ ├── miniupnpcstrings.h.in │ ├── miniupnpctypes.h │ ├── miniwget.c │ ├── miniwget.h │ ├── minixml.c │ ├── minixml.h │ ├── minixmlvalid.c │ ├── portlistingparse.c │ ├── portlistingparse.h │ ├── portlistingparse.o │ ├── pymoduletest.py │ ├── receivedata.c │ ├── receivedata.h │ ├── setup.py │ ├── setupmingw32.py │ ├── testigddescparse.c │ ├── testminiwget.c │ ├── testminiwget.sh │ ├── testminixml.c │ ├── testupnpigd.py │ ├── testupnpreplyparse.c │ ├── updateminiupnpcstrings.sh │ ├── upnpc.c │ ├── upnpcommands.c │ ├── upnpcommands.h │ ├── upnperrors.c │ ├── upnperrors.h │ ├── upnpreplyparse.c │ ├── upnpreplyparse.h │ └── wingenminiupnpcstrings.c └── linux_installation_guide /Chain/.gitignore: -------------------------------------------------------------------------------- 1 | *.opendb 2 | *~ 3 | x64 4 | .vs 5 | *.sdf 6 | *.user 7 | *.suo 8 | *.out 9 | *.VC.db 10 | *.VC.opendb 11 | *.bytes 12 | *.opensdf 13 | /bin 14 | /Debug 15 | /Release 16 | /out 17 | /logs 18 | /CMakeCache* 19 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/AssertException.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/AssertException.h" 2 | 3 | #ifndef UNITTEST_NO_EXCEPTIONS 4 | 5 | namespace UnitTest { 6 | 7 | AssertException::AssertException() 8 | {} 9 | 10 | AssertException::~AssertException() throw() 11 | {} 12 | 13 | } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/Checks.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/Checks.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | namespace { 7 | 8 | void CheckStringsEqual(TestResults& results, char const* expected, char const* actual, 9 | TestDetails const& details) 10 | { 11 | using namespace std; 12 | 13 | if ((expected && actual) ? strcmp(expected, actual) : (expected || actual)) 14 | { 15 | UnitTest::MemoryOutStream stream; 16 | stream << "Expected " << (expected ? expected : "") << " but was " << (actual ? actual : ""); 17 | 18 | results.OnTestFailure(details, stream.GetText()); 19 | } 20 | } 21 | 22 | } 23 | 24 | 25 | void CheckEqual(TestResults& results, char const* expected, char const* actual, 26 | TestDetails const& details) 27 | { 28 | CheckStringsEqual(results, expected, actual, details); 29 | } 30 | 31 | void CheckEqual(TestResults& results, char* expected, char* actual, 32 | TestDetails const& details) 33 | { 34 | CheckStringsEqual(results, expected, actual, details); 35 | } 36 | 37 | void CheckEqual(TestResults& results, char* expected, char const* actual, 38 | TestDetails const& details) 39 | { 40 | CheckStringsEqual(results, expected, actual, details); 41 | } 42 | 43 | void CheckEqual(TestResults& results, char const* expected, char* actual, 44 | TestDetails const& details) 45 | { 46 | CheckStringsEqual(results, expected, actual, details); 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/CurrentTest.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/CurrentTest.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | UNITTEST_LINKAGE TestResults*& CurrentTest::Results() 7 | { 8 | static TestResults* testResults = nullptr; 9 | return testResults; 10 | } 11 | 12 | UNITTEST_LINKAGE const TestDetails*& CurrentTest::Details() 13 | { 14 | static const TestDetails* testDetails = nullptr; 15 | return testDetails; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/DeferredTestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/Config.h" 2 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 3 | 4 | #include "UnitTest++/DeferredTestReporter.h" 5 | #include "UnitTest++/TestDetails.h" 6 | 7 | using namespace UnitTest; 8 | 9 | void DeferredTestReporter::ReportTestStart(TestDetails const& details) 10 | { 11 | m_results.push_back(DeferredTestResult(details.suiteName, details.testName)); 12 | } 13 | 14 | void DeferredTestReporter::ReportFailure(TestDetails const& details, char const* failure) 15 | { 16 | DeferredTestResult& r = m_results.back(); 17 | r.failed = true; 18 | r.failures.push_back(DeferredTestFailure(details.lineNumber, failure)); 19 | r.failureFile = details.filename; 20 | } 21 | 22 | void DeferredTestReporter::ReportTestFinish(TestDetails const&, float secondsElapsed) 23 | { 24 | DeferredTestResult& r = m_results.back(); 25 | r.timeElapsed = secondsElapsed; 26 | } 27 | 28 | DeferredTestReporter::DeferredTestResultList& DeferredTestReporter::GetResults() 29 | { 30 | return m_results; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/DeferredTestResult.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** Windows stuff 3 | */ 4 | #if defined(_WIN32) /* { */ 5 | 6 | #if !defined(_CRT_SECURE_NO_WARNINGS) 7 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 8 | #endif 9 | 10 | #endif /* } */ 11 | 12 | #include "UnitTest++/Config.h" 13 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 14 | 15 | #include "UnitTest++/DeferredTestResult.h" 16 | #include 17 | 18 | namespace UnitTest 19 | { 20 | 21 | DeferredTestFailure::DeferredTestFailure() 22 | : lineNumber(-1) 23 | { 24 | failureStr[0] = '\0'; 25 | } 26 | 27 | DeferredTestFailure::DeferredTestFailure(int lineNumber_, const char* failureStr_) 28 | : lineNumber(lineNumber_) 29 | { 30 | UNIITEST_NS_QUAL_STD(strcpy)(failureStr, failureStr_); 31 | } 32 | 33 | DeferredTestResult::DeferredTestResult() 34 | : suiteName("") 35 | , testName("") 36 | , failureFile("") 37 | , timeElapsed(0.0f) 38 | , failed(false) 39 | {} 40 | 41 | DeferredTestResult::DeferredTestResult(char const* suite, char const* test) 42 | : suiteName(suite) 43 | , testName(test) 44 | , failureFile("") 45 | , timeElapsed(0.0f) 46 | , failed(false) 47 | {} 48 | 49 | DeferredTestResult::~DeferredTestResult() 50 | {} 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/Posix/SignalTranslator.cpp: -------------------------------------------------------------------------------- 1 | #include "SignalTranslator.h" 2 | 3 | namespace UnitTest { 4 | 5 | sigjmp_buf* SignalTranslator::s_jumpTarget = 0; 6 | 7 | namespace { 8 | 9 | void SignalHandler(int sig) 10 | { 11 | siglongjmp(*SignalTranslator::s_jumpTarget, sig ); 12 | } 13 | 14 | } 15 | 16 | 17 | SignalTranslator::SignalTranslator() 18 | { 19 | m_oldJumpTarget = s_jumpTarget; 20 | s_jumpTarget = &m_currentJumpTarget; 21 | 22 | struct sigaction action; 23 | action.sa_flags = 0; 24 | action.sa_handler = SignalHandler; 25 | sigemptyset( &action.sa_mask ); 26 | 27 | sigaction( SIGSEGV, &action, &m_old_SIGSEGV_action ); 28 | sigaction( SIGFPE, &action, &m_old_SIGFPE_action ); 29 | sigaction( SIGTRAP, &action, &m_old_SIGTRAP_action ); 30 | sigaction( SIGBUS, &action, &m_old_SIGBUS_action ); 31 | sigaction( SIGILL, &action, &m_old_SIGBUS_action ); 32 | } 33 | 34 | SignalTranslator::~SignalTranslator() 35 | { 36 | sigaction( SIGILL, &m_old_SIGBUS_action, 0 ); 37 | sigaction( SIGBUS, &m_old_SIGBUS_action, 0 ); 38 | sigaction( SIGTRAP, &m_old_SIGTRAP_action, 0 ); 39 | sigaction( SIGFPE, &m_old_SIGFPE_action, 0 ); 40 | sigaction( SIGSEGV, &m_old_SIGSEGV_action, 0 ); 41 | 42 | s_jumpTarget = m_oldJumpTarget; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/Posix/TimeHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "TimeHelpers.h" 2 | #include 3 | 4 | namespace UnitTest { 5 | 6 | Timer::Timer() 7 | { 8 | m_startTime.tv_sec = 0; 9 | m_startTime.tv_usec = 0; 10 | } 11 | 12 | void Timer::Start() 13 | { 14 | gettimeofday(&m_startTime, 0); 15 | } 16 | 17 | double Timer::GetTimeInMs() const 18 | { 19 | struct timeval currentTime; 20 | gettimeofday(¤tTime, 0); 21 | 22 | double const dsecs = currentTime.tv_sec - m_startTime.tv_sec; 23 | double const dus = currentTime.tv_usec - m_startTime.tv_usec; 24 | 25 | return (dsecs * 1000.0) + (dus / 1000.0); 26 | } 27 | 28 | void TimeHelpers::SleepMs(int ms) 29 | { 30 | usleep(static_cast(ms * 1000)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/RequiredCheckException.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/RequiredCheckException.h" 2 | 3 | #ifndef UNITTEST_NO_EXCEPTIONS 4 | 5 | namespace UnitTest { 6 | 7 | RequiredCheckException::RequiredCheckException() 8 | { 9 | } 10 | 11 | RequiredCheckException::~RequiredCheckException() throw() 12 | { 13 | } 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/RequiredCheckTestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/RequiredCheckTestReporter.h" 2 | 3 | #include "UnitTest++/CurrentTest.h" 4 | #include "UnitTest++/TestResults.h" 5 | 6 | namespace UnitTest { 7 | 8 | RequiredCheckTestReporter::RequiredCheckTestReporter(TestResults& results) 9 | : m_results(results) 10 | , m_originalTestReporter(results.m_testReporter) 11 | , m_throwingReporter(results.m_testReporter) 12 | , m_continue(0) 13 | { 14 | m_results.m_testReporter = &m_throwingReporter; 15 | } 16 | 17 | RequiredCheckTestReporter::~RequiredCheckTestReporter() 18 | { 19 | m_results.m_testReporter = m_originalTestReporter; 20 | } 21 | 22 | bool RequiredCheckTestReporter::Next() 23 | { 24 | return m_continue++ == 0; 25 | } 26 | } -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/Test.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/Config.h" 2 | #include "UnitTest++/Test.h" 3 | #include "UnitTest++/TestList.h" 4 | #include "UnitTest++/TestResults.h" 5 | #include "UnitTest++/AssertException.h" 6 | #include "UnitTest++/MemoryOutStream.h" 7 | #include "UnitTest++/ExecuteTest.h" 8 | 9 | #ifdef UNITTEST_POSIX 10 | #include "UnitTest++/Posix/SignalTranslator.h" 11 | #endif 12 | 13 | namespace UnitTest { 14 | 15 | TestList& Test::GetTestList() 16 | { 17 | static TestList s_list; 18 | return s_list; 19 | } 20 | 21 | Test::Test(char const* testName, char const* suiteName, char const* filename, int lineNumber) 22 | : m_details(testName, suiteName, filename, lineNumber) 23 | , m_nextTest(0) 24 | , m_isMockTest(false) 25 | {} 26 | 27 | Test::~Test() 28 | {} 29 | 30 | void Test::Run() 31 | { 32 | ExecuteTest(*this, m_details, m_isMockTest); 33 | } 34 | 35 | void Test::RunImpl() const 36 | {} 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/TestDetails.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TestDetails.h" 2 | 3 | namespace UnitTest { 4 | 5 | TestDetails::TestDetails(char const* testName_, char const* suiteName_, char const* filename_, int lineNumber_) 6 | : suiteName(suiteName_) 7 | , testName(testName_) 8 | , filename(filename_) 9 | , lineNumber(lineNumber_) 10 | , timeConstraintExempt(false) 11 | {} 12 | 13 | TestDetails::TestDetails(const TestDetails& details, int lineNumber_) 14 | : suiteName(details.suiteName) 15 | , testName(details.testName) 16 | , filename(details.filename) 17 | , lineNumber(lineNumber_) 18 | , timeConstraintExempt(details.timeConstraintExempt) 19 | {} 20 | 21 | 22 | } 23 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/TestList.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TestList.h" 2 | #include "UnitTest++/Test.h" 3 | 4 | #include 5 | 6 | namespace UnitTest { 7 | 8 | TestList::TestList() 9 | : m_head(0) 10 | , m_tail(0) 11 | {} 12 | 13 | void TestList::Add(Test* test) 14 | { 15 | if (m_tail == 0) 16 | { 17 | assert(m_head == 0); 18 | m_head = test; 19 | m_tail = test; 20 | } 21 | else 22 | { 23 | m_tail->m_nextTest = test; 24 | m_tail = test; 25 | } 26 | } 27 | 28 | Test* TestList::GetHead() const 29 | { 30 | return m_head; 31 | } 32 | 33 | ListAdder::ListAdder(TestList& list, Test* test) 34 | { 35 | list.Add(test); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/TestReporter.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TestReporter.h" 2 | 3 | namespace UnitTest { 4 | 5 | TestReporter::~TestReporter() 6 | {} 7 | 8 | } 9 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/TestResults.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TestResults.h" 2 | #include "UnitTest++/TestReporter.h" 3 | 4 | #include "UnitTest++/TestDetails.h" 5 | 6 | namespace UnitTest { 7 | 8 | TestResults::TestResults(TestReporter* testReporter) 9 | : m_testReporter(testReporter) 10 | , m_totalTestCount(0) 11 | , m_failedTestCount(0) 12 | , m_failureCount(0) 13 | , m_currentTestFailed(false) 14 | {} 15 | 16 | void TestResults::OnTestStart(TestDetails const& test) 17 | { 18 | ++m_totalTestCount; 19 | m_currentTestFailed = false; 20 | if (m_testReporter) 21 | m_testReporter->ReportTestStart(test); 22 | } 23 | 24 | void TestResults::OnTestFailure(TestDetails const& test, char const* failure) 25 | { 26 | ++m_failureCount; 27 | if (!m_currentTestFailed) 28 | { 29 | ++m_failedTestCount; 30 | m_currentTestFailed = true; 31 | } 32 | 33 | if (m_testReporter) 34 | m_testReporter->ReportFailure(test, failure); 35 | } 36 | 37 | void TestResults::OnTestFinish(TestDetails const& test, float secondsElapsed) 38 | { 39 | if (m_testReporter) 40 | m_testReporter->ReportTestFinish(test, secondsElapsed); 41 | } 42 | 43 | int TestResults::GetTotalTestCount() const 44 | { 45 | return m_totalTestCount; 46 | } 47 | 48 | int TestResults::GetFailedTestCount() const 49 | { 50 | return m_failedTestCount; 51 | } 52 | 53 | int TestResults::GetFailureCount() const 54 | { 55 | return m_failureCount; 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/TimeConstraint.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TimeConstraint.h" 2 | #include "UnitTest++/TestResults.h" 3 | #include "UnitTest++/MemoryOutStream.h" 4 | #include "UnitTest++/CurrentTest.h" 5 | 6 | namespace UnitTest { 7 | 8 | 9 | TimeConstraint::TimeConstraint(int ms, TestDetails const& details, int lineNumber) 10 | : m_details(details, lineNumber) 11 | , m_maxMs(ms) 12 | { 13 | m_timer.Start(); 14 | } 15 | 16 | TimeConstraint::~TimeConstraint() 17 | { 18 | double const totalTimeInMs = m_timer.GetTimeInMs(); 19 | if (totalTimeInMs > m_maxMs) 20 | { 21 | MemoryOutStream stream; 22 | stream << "Time constraint failed. Expected to run test under " << m_maxMs << 23 | "ms but took " << totalTimeInMs << "ms."; 24 | 25 | CurrentTest::Results()->OnTestFailure(m_details, stream.GetText()); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Chain/libraries/UnitTest++/Win32/TimeHelpers.cpp: -------------------------------------------------------------------------------- 1 | #include "UnitTest++/TimeHelpers.h" 2 | 3 | #define WIN32_LEAN_AND_MEAN 4 | #include 5 | 6 | namespace UnitTest { 7 | 8 | Timer::Timer() 9 | : m_threadHandle(::GetCurrentThread()) 10 | , m_startTime(0) 11 | { 12 | #if defined(UNITTEST_WIN32) && (_MSC_VER == 1200) // VC6 doesn't have DWORD_PTR 13 | typedef unsigned long DWORD_PTR; 14 | #endif 15 | 16 | DWORD_PTR systemMask; 17 | ::GetProcessAffinityMask(GetCurrentProcess(), &m_processAffinityMask, &systemMask); 18 | ::SetThreadAffinityMask(m_threadHandle, 1); 19 | ::QueryPerformanceFrequency(reinterpret_cast< LARGE_INTEGER* >(&m_frequency)); 20 | ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); 21 | } 22 | 23 | void Timer::Start() 24 | { 25 | m_startTime = GetTime(); 26 | } 27 | 28 | double Timer::GetTimeInMs() const 29 | { 30 | __int64 const elapsedTime = GetTime() - m_startTime; 31 | double const seconds = double(elapsedTime) / double(m_frequency); 32 | return seconds * 1000.0; 33 | } 34 | 35 | __int64 Timer::GetTime() const 36 | { 37 | LARGE_INTEGER curTime; 38 | ::SetThreadAffinityMask(m_threadHandle, 1); 39 | ::QueryPerformanceCounter(&curTime); 40 | ::SetThreadAffinityMask(m_threadHandle, m_processAffinityMask); 41 | return curTime.QuadPart; 42 | } 43 | 44 | void TimeHelpers::SleepMs(int ms) 45 | { 46 | ::Sleep(ms); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /Chain/libraries/api/ConversionFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace thinkyoung { 4 | namespace api { 5 | 6 | fc::variant fc_ip_endpoint_to_variant(const fc::ip::endpoint& endpoint) 7 | { 8 | return fc::variant(std::string(endpoint)); 9 | } 10 | 11 | fc::ip::endpoint variant_to_fc_ip_endpoint(const fc::variant& endpoint_as_variant) 12 | { 13 | return fc::ip::endpoint::from_string(endpoint_as_variant.as_string()); 14 | } 15 | 16 | fc::variant time_interval_in_seconds_to_variant(const fc::microseconds time_interval) 17 | { 18 | return time_interval.count() / fc::seconds(1).count(); 19 | } 20 | 21 | fc::microseconds variant_to_time_interval_in_seconds(const fc::variant& time_interval_as_variant) 22 | { 23 | return fc::seconds(time_interval_as_variant.as_int64()); 24 | } 25 | 26 | } 27 | } // end namespace thinkyoung::api 28 | -------------------------------------------------------------------------------- /Chain/libraries/blockchain/ChainDatabase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/blockchain/ChainDatabase.cpp -------------------------------------------------------------------------------- /Chain/libraries/blockchain/ChainInterface.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/blockchain/ChainInterface.cpp -------------------------------------------------------------------------------- /Chain/libraries/blockchain/EventOperations.cpp: -------------------------------------------------------------------------------- 1 | #include "blockchain/EventOperations.hpp" 2 | #include "blockchain/ContractEntry.hpp" 3 | #include "blockchain/TransactionEvaluationState.hpp" 4 | #include "blockchain/ChainInterface.hpp" 5 | #include "blockchain/Exceptions.hpp" 6 | 7 | 8 | namespace thinkyoung 9 | { 10 | namespace blockchain 11 | { 12 | 13 | void EventOperation::evaluate(TransactionEvaluationState& eval_state)const 14 | { 15 | try { 16 | if (!eval_state.evaluate_contract_result) 17 | FC_CAPTURE_AND_THROW(not_be_result_of_execute, (type)); 18 | 19 | oContractEntry entry = eval_state._current_state->get_contract_entry(id); 20 | if (!entry.valid()) 21 | FC_CAPTURE_AND_THROW(contract_not_exist); 22 | 23 | if (event_param.length() > EVENT_PARAM_MAX_LEN) 24 | FC_CAPTURE_AND_THROW(event_parameter_length_over_limit, ("the parameter length of event function is over limit")); 25 | 26 | eval_state.event_vector.push_back(*this); 27 | } FC_CAPTURE_AND_RETHROW((*this)) 28 | } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Chain/libraries/blockchain/ImessageOperations.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace thinkyoung { 9 | namespace blockchain { 10 | void ImessageMemoOperation::evaluate(TransactionEvaluationState& eval_state) const 11 | { 12 | try 13 | { 14 | FC_ASSERT(!imessage.empty()); 15 | if (this->imessage.size() > ALP_BLOCKCHAIN_MAX_MESSAGE_SIZE) 16 | { 17 | FC_CAPTURE_AND_THROW(message_too_long, (imessage.size())); 18 | } 19 | auto fee = Asset(eval_state._current_state->get_imessage_need_fee(imessage), 0); 20 | eval_state.imessage_length = imessage.size(); 21 | eval_state.required_fees += fee; 22 | } FC_CAPTURE_AND_RETHROW((*this)) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chain/libraries/blockchain/PropertyEntry.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace blockchain { 6 | 7 | void PropertyEntry::sanity_check(const ChainInterface& db)const 8 | { 9 | try { 10 | FC_ASSERT(!value.is_null()); 11 | } FC_CAPTURE_AND_RETHROW((*this)) 12 | } 13 | 14 | oPropertyEntry PropertyEntry::lookup(const ChainInterface& db, const PropertyIdType id) 15 | { 16 | try { 17 | return db.property_lookup_by_id(id); 18 | } FC_CAPTURE_AND_RETHROW((id)) 19 | } 20 | 21 | void PropertyEntry::store(ChainInterface& db, const PropertyIdType id, const PropertyEntry& entry) 22 | { 23 | try { 24 | db.property_insert_into_id_map(id, entry); 25 | } FC_CAPTURE_AND_RETHROW((id)(entry)) 26 | } 27 | 28 | void PropertyEntry::remove(ChainInterface& db, const PropertyIdType id) 29 | { 30 | try { 31 | const oPropertyEntry prev_entry = db.lookup(id); 32 | if (prev_entry.valid()) 33 | db.property_erase_from_id_map(id); 34 | } FC_CAPTURE_AND_RETHROW((id)) 35 | } 36 | 37 | } 38 | } // thinkyoung::blockchain 39 | -------------------------------------------------------------------------------- /Chain/libraries/blockchain/StorageOperations.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/blockchain/StorageOperations.cpp -------------------------------------------------------------------------------- /Chain/libraries/blockchain/Transaction.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/blockchain/Transaction.cpp -------------------------------------------------------------------------------- /Chain/libraries/blockchain/TransactionEvaluationState.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/blockchain/TransactionEvaluationState.cpp -------------------------------------------------------------------------------- /Chain/libraries/blockchain/TransactionOperations.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | namespace thinkyoung { 4 | namespace blockchain { 5 | 6 | void TransactionOperation::evaluate(TransactionEvaluationState& eval_state)const 7 | { 8 | try { 9 | TransactionIdType id= eval_state.trx.result_trx_id; 10 | eval_state.evaluate(trx); 11 | eval_state._current_state->store(trx.id(), ResultTIdEntry(id)); 12 | eval_state._current_state->store(id, RequestIdEntry(trx.id())); 13 | } 14 | FC_CAPTURE_AND_RETHROW((*this)) 15 | } 16 | 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Chain/libraries/client/DebugApi.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #ifndef WIN32 8 | #include 9 | #endif 10 | 11 | namespace thinkyoung { 12 | namespace client { 13 | namespace detail { 14 | 15 | std::string ClientImpl::debug_get_client_name() const 16 | { 17 | // set limit in sandbox state 18 | if (_chain_db->get_is_in_sandbox()) 19 | FC_THROW_EXCEPTION(sandbox_command_forbidden, "in sandbox, this command is forbidden, you cannot call it!"); 20 | 21 | return this->_config.client_debug_name; 22 | } 23 | 24 | } 25 | } 26 | } // namespace thinkyoung::client::detail 27 | -------------------------------------------------------------------------------- /Chain/libraries/client/Messages.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace thinkyoung { 3 | namespace client { 4 | 5 | const MessageTypeEnum TrxMessage::type = MessageTypeEnum::trx_message_type; 6 | const MessageTypeEnum BlockMessage::type = MessageTypeEnum::block_message_type; 7 | const MessageTypeEnum BatchTrxMessage::type = MessageTypeEnum::batch_trx_message_type; 8 | 9 | } 10 | } // thinkyoung::client 11 | -------------------------------------------------------------------------------- /Chain/libraries/glua/README.md: -------------------------------------------------------------------------------- 1 | glua 2 | ===== 3 | 4 | glua�����ں�������������lua5.3.2�����Բ����н϶����� 5 | 6 | 7 | # Dependencies 8 | 9 | * boost 1.55 10 | 11 | * 宏增加WIN32 12 | 13 | * 命令行考虑增加/W4 -------------------------------------------------------------------------------- /Chain/libraries/glua/glua_api_types.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | GluaModuleByteStream::GluaModuleByteStream() 5 | { 6 | is_bytes = false; 7 | contract_level = CONTRACT_LEVEL_TEMP; 8 | contract_state = CONTRACT_STATE_VALID; 9 | } 10 | 11 | GluaModuleByteStream::~GluaModuleByteStream() 12 | { 13 | contract_apis.clear(); 14 | offline_apis.clear(); 15 | contract_emit_events.clear(); 16 | } -------------------------------------------------------------------------------- /Chain/libraries/glua/glua_astparser.cpp: -------------------------------------------------------------------------------- 1 | #include "glua/glua_astparser.h" 2 | #include "glua/lparser.h" 3 | #include "glua/lfunc.h" 4 | #include "glua/lobject.h" 5 | 6 | namespace glua { 7 | namespace parser { 8 | 9 | 10 | } // end of glua::parser 11 | } -------------------------------------------------------------------------------- /Chain/libraries/glua/glua_loader.cpp: -------------------------------------------------------------------------------- 1 | #include "glua/glua_loader.h" 2 | 3 | namespace thinkyoung 4 | { 5 | namespace lua 6 | { 7 | namespace parser 8 | { 9 | /* 10 | LuaLoader::LuaLoader(GluaModuleByteStream *stream) 11 | : _stream(stream) 12 | { 13 | } 14 | 15 | 16 | LuaLoader::~LuaLoader() 17 | { 18 | } 19 | 20 | void LuaLoader::load_bytecode() 21 | { 22 | // TODO 23 | } 24 | */ 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Chain/libraries/glua/glua_vm.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace glua 4 | { 5 | namespace vm 6 | { 7 | VM::VM() 8 | { 9 | 10 | } 11 | 12 | VM::~VM() 13 | { 14 | 15 | } 16 | 17 | void VM::execute(VMStateP state) 18 | { 19 | // TODO 20 | } 21 | 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Chain/libraries/glua/init_debugger_info.db: -------------------------------------------------------------------------------- 1 | add,@tests_typed/full_correct_typed.glua,14,17,20,22,25,30,50; 2 | -------------------------------------------------------------------------------- /Chain/libraries/glua/language_server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/language_server.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/language_server.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/language_server.md -------------------------------------------------------------------------------- /Chain/libraries/glua/ljsonrpclib.cpp: -------------------------------------------------------------------------------- 1 | #define ljsonrpclib_cpp 2 | 3 | #include 4 | #include "glua/lprefix.h" 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "glua/lua.h" 17 | 18 | #include "glua/lauxlib.h" 19 | #include "glua/lualib.h" 20 | #include "glua/thinkyoung_lua_api.h" 21 | 22 | #undef LUA_JSONRPC_VERSION 23 | #define LUA_JSONRPC_VERSION "1.0" 24 | 25 | static const luaL_Reg jsonrpclib[] = { 26 | // { "listen", lualib_http_listen }, 27 | { "version", nullptr }, 28 | { nullptr, nullptr } 29 | }; 30 | 31 | 32 | LUAMOD_API int luaopen_jsonrpc(lua_State *L) { 33 | luaL_newlib(L, jsonrpclib); 34 | lua_pushstring(L, LUA_JSONRPC_VERSION); 35 | lua_setfield(L, -2, "version"); 36 | return 1; 37 | } 38 | -------------------------------------------------------------------------------- /Chain/libraries/glua/lmathlib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/lmathlib.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/lparser.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/lparser.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/lprefix.cpp: -------------------------------------------------------------------------------- 1 | #define lprefix_cpp 2 | 3 | #include "glua/lprefix.h" 4 | #include 5 | #include 6 | -------------------------------------------------------------------------------- /Chain/libraries/glua/lremote_debugger.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/lremote_debugger.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/lstate.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/lstate.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/ltable.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/ltable.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/ltablib.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/ltablib.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/ltype_checker_type_info.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/ltype_checker_type_info.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/.gitignore: -------------------------------------------------------------------------------- 1 | /tmp* 2 | /*.out.* -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/error_syntax.lua: -------------------------------------------------------------------------------- 1 | function abc() 2 | print('abc') 3 | -- goto done 4 | end 5 | 6 | ::done:: 7 | print(123) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test1.lua: -------------------------------------------------------------------------------- 1 | local demo2 = import_contract_from_address 'id_demo2' 2 | 3 | function mylua() 4 | 5 | -- printff("mylua") 6 | 7 | print(ADD(1,2)) 8 | 9 | print(ADD(3,4)) 10 | 11 | pprint({1,2,3,11,7}) 12 | 13 | 14 | pprint('demo2 used in test1.lua', demo2.id) 15 | 16 | local p1 = {name="thinkyoung", age=1} 17 | p1.nested = {nested=p1, groups="groups members"} 18 | pprint("p1", p1) 19 | 20 | local hello = require 'hello' 21 | 22 | hello.say_hello('thinkyoung') 23 | 24 | print(hello.test_error()) 25 | 26 | print("after call test_error()") 27 | 28 | -- require('tests_lua/test2.lua') 29 | 30 | 31 | -- _ENV['abc'] = 123 32 | 33 | env2 = {["abc"]=1234} 34 | 35 | -- local package = require 'package' 36 | 37 | -- print(package.loaded) 38 | 39 | end 40 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test2.lua: -------------------------------------------------------------------------------- 1 | print("hello from lua") 2 | 3 | env2 = {["abc"]=1234} 4 | 5 | -- _ENV['abc'] = 1234 6 | 7 | print(ADD(1,2)) 8 | 9 | print(ADD(3,4)) 10 | 11 | 12 | for i = 1, 6 do 13 | print('hello, for ' .. i) 14 | end 15 | 16 | local contract_demo1 = import_contract 'demo2' -- or import_contract('demo1') 17 | 18 | contract_demo1.init() 19 | contract_demo1.start() 20 | 21 | print('test2 demo done') 22 | 23 | local i = 1 24 | 25 | ::demo_goto:: 26 | if i < 5 then 27 | print("goto line ", i) 28 | i = i + 1 29 | -- goto demo_goto 30 | end 31 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test3.lua: -------------------------------------------------------------------------------- 1 | print("Hello, this is test3.lua\n") 2 | 3 | local M = {} 4 | 5 | local fname = 'abc' 6 | 7 | function M:init() 8 | pprint('test3 contract demo init') 9 | -- local dd = import_contract 'not_found' 10 | -- local dd2 = import_contract('not_found') 11 | local storage = {} 12 | storage['name'] = 123 13 | local abc = "\x23\xa3\u{1234}\5\6\zabc" 14 | print(abc) 15 | local a2 = [[abcdef]] 16 | local d = 123.45 + 2 17 | local e = fname 18 | end 19 | 20 | offline function M:start(name) 21 | pprint('test3 contract demo start ', name) 22 | end 23 | 24 | -- a=1 25 | 26 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test4.lua: -------------------------------------------------------------------------------- 1 | local t = require 'math' 2 | t.hello = 123 3 | local d = t.hello 4 | -- local c = _G.require 5 | 6 | local hello2 = 456 7 | 8 | local M = {} 9 | 10 | -- M2 = {} 11 | 12 | function M:init() 13 | local age = 25 14 | end 15 | 16 | function M:start() 17 | local age = 100 18 | end 19 | 20 | function M.b() 21 | -- d = c 22 | -- local e = _ENV 23 | local c = 1 24 | local demo2 = import_contract 'demo2' 25 | end 26 | 27 | local f2 = function() 28 | local c = 1 29 | local f1 = function () 30 | local n = 0 31 | return function() 32 | n = n + 1 33 | return function() 34 | return c + n 35 | end 36 | end 37 | end 38 | local e1 = f1() 39 | return e1 40 | end 41 | 42 | pprint('this is test4.lua\n') 43 | 44 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_c_function.lua: -------------------------------------------------------------------------------- 1 | print('hi, this is test c function\n') 2 | local thinkyoung = require 'thinkyoung' 3 | -- thinkyoung.check(0) 4 | local result = ADD(3, 4) 5 | thinkyoung.check_equal(result, 7) 6 | 7 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_c_module_inject.lua: -------------------------------------------------------------------------------- 1 | print("Hi, this is test c module inject caes\n") 2 | 3 | local hello = require 'hello' 4 | local thinkyoung = require 'thinkyoung' 5 | 6 | hello.say_hello('thinkyoung') 7 | 8 | print(hello.test_error()) 9 | 10 | print("after call test_error()") 11 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_compile_error.lua: -------------------------------------------------------------------------------- 1 | function a 2 | if 1>2 3 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_contract_transfer.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | 4 | function M:init() 5 | print("test contract transfer caller") 6 | 7 | local contract_transfer_demo = import_contract 'contract_transfer_demo' 8 | local res = contract_transfer_demo:start() 9 | pprint("transfer demo start response is ", res) 10 | end 11 | 12 | function M:start() 13 | 14 | end 15 | 16 | return M 17 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_debugger.lua: -------------------------------------------------------------------------------- 1 | print("Hello, this is test_debugger.lua") 2 | 3 | local M = {} 4 | 5 | local fname = 'abc' 6 | 7 | function M:init() 8 | pprint('test3 contract demo init') 9 | end 10 | 11 | function M:start(name) 12 | pprint('test3 contract demo start ', name) 13 | local storage = {} 14 | storage['name'] = 123 15 | debugger() 16 | local abc = "\x23\xa3\u{1234}\5\6\z 17 | abc" 18 | print(abc) 19 | local a2 = [[abcdef]] 20 | debugger() 21 | local d = 123.45 22 | local e = fname 23 | debugger() 24 | end 25 | 26 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_error.lua: -------------------------------------------------------------------------------- 1 | print("test error case\n") 2 | local thinkyoung = require 'thinkyoung' 3 | thinkyoung.check_equal(6, 7) 4 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_error_syntax.lua: -------------------------------------------------------------------------------- 1 | if 1 then function abc() 2 | print('abc') 3 | goto done 4 | end 5 | 6 | ::done:: 7 | print(123) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_error_use_api.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:init() 4 | pprint('test error use api case init') 5 | local demo2 = import_contract 'demo2' 6 | -- demo2:not_found('hi') 7 | -- transfer_from_contract_to_address(100, 50.5) 8 | end 9 | 10 | function M:start() 11 | pprint("test error use api case start") 12 | local b = string.find('a') 13 | local b = {} 14 | local c = b.hi() 15 | local a = nil 16 | a.hi() 17 | local d = import_contract() 18 | pprint(d) 19 | d.hi() 20 | end 21 | 22 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_exit_contract.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:init() 4 | 5 | end 6 | 7 | function M:start() 8 | pprint("test exit contract start") 9 | local a = 1 > 'a' 10 | exit('hello') 11 | local thinkyoung = require 'thinkyoung' 12 | thinkyoung.error("error") 13 | pprint("after exit") 14 | end 15 | 16 | pprint("test exit contract loaded") 17 | 18 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_for_loop_goto.lua: -------------------------------------------------------------------------------- 1 | e = {name="thinkyoung", age=25} 2 | 3 | for k in pairs(e) do 4 | print(k, e[k]) 5 | end 6 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_get_global_table.lua: -------------------------------------------------------------------------------- 1 | env2 = {["abc"]=1234, age=25} 2 | print("hi, this is test get global table case\n") -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_import_not_found.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:init() 4 | pprint('init import not found') 5 | end 6 | 7 | function M:start() 8 | pprint('start import not found') 9 | local demo2 = import_contract 'not_found' 10 | end 11 | 12 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_load_contract.lua: -------------------------------------------------------------------------------- 1 | print("hi, this is test load contract case\n") 2 | 3 | local demo2 = import_contract 'demo2' -- TODO: load storage inited by demo2 4 | -- print(demo2.storage.name) 5 | -- demo2.set_storage(name, 'hi') 6 | 7 | -- demo2.init() -- this will error 8 | demo2.start() 9 | print(demo2) 10 | -- demo2.name = "modified contract name" 11 | print('demo2 contract name: ', demo2.name) 12 | 13 | -- TODO: after called contract and close lua_State, save storage to thinkyoung 14 | 15 | -- demo2.storage.rollback() -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_no_return_contract.lua: -------------------------------------------------------------------------------- 1 | print("hello") -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_stop_vm.lua: -------------------------------------------------------------------------------- 1 | print('test stop vm case\n') 2 | local thinkyoung = require 'thinkyoung' 3 | thinkyoung.stop_vm() 4 | 5 | local n = 0 6 | for i = 1, 10 do 7 | n = n + i 8 | print("after stop vm") 9 | end 10 | print(n) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_tostring.lua: -------------------------------------------------------------------------------- 1 | local a={name=1,b=print,c={a=1,b="hi"}} 2 | b = tostring(a) 3 | c = tojsonstring(a) 4 | print(b) 5 | pprint(c) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_upval.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:init() 4 | 5 | end 6 | 7 | function M:get(gift_num) 8 | local gift = math.floor(1.2) 9 | local a = b.c(123) 10 | end 11 | 12 | print ("123") 13 | 14 | return M 15 | 16 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_use_error_function.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_lua/test_use_error_function.lua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_without_init.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:start() 4 | pprint('start without init') 5 | end 6 | 7 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/test_wrong_contract.lua: -------------------------------------------------------------------------------- 1 | local t = require 'math' 2 | t.hello = 123 3 | local d = t.hello 4 | -- local c = _G.require 5 | 6 | local hello2 = 456 7 | 8 | local M = {} 9 | 10 | -- M2 = {} 11 | 12 | function M.init2() 13 | local age = 25 14 | end 15 | 16 | 17 | function M.b() 18 | -- d = c 19 | -- local e = _ENV 20 | local c = 1 21 | end 22 | 23 | print('this is test_wrong_contract.lua\n') 24 | 25 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_lua/测试中文.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M:init() 4 | pprint('init chinese path') 5 | end 6 | 7 | function M:start() 8 | pprint('start chinese path') 9 | end 10 | 11 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/bin_and_un_op_type.lua: -------------------------------------------------------------------------------- 1 | let storage = {} 2 | let a4 = #storage.name + 1 3 | let a = 123.45 + 2 + #storage.name + tonumber('123') + "aaa" + 1 4 | let b = 123.45 + 2 + #storage.name + tonumber('123') + 1 5 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/call_without_brackets.lua: -------------------------------------------------------------------------------- 1 | pprint 'hi' 2 | let a = 1 3 | pprint(a) 4 | pprint '123' 5 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/call_without_brackets_error.lua: -------------------------------------------------------------------------------- 1 | let a = 1 2 | pprint a -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/correct_nested_table.glua: -------------------------------------------------------------------------------- 1 | let nested_table1 = [ {name='hi',age=100} ] 2 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/declare_with_type.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/declare_with_type.lua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/duplicate_return.glua: -------------------------------------------------------------------------------- 1 | return 1 2 | return 1 3 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/empty_correct_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | let M: Contract = {} 4 | 5 | function M:init() 6 | end 7 | 8 | function M:start() 9 | -- pprint("hi") 10 | end 11 | 12 | return M 13 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/full_demo.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/full_demo.lua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/function_type_and_call.lua: -------------------------------------------------------------------------------- 1 | local add1 = function (a: number, b: number) 2 | return a + b 3 | end 4 | 5 | local function add2(a: number, b) 6 | return add1(a, tonumber(b)) 7 | end 8 | 9 | let add3: (number, number) => number 10 | 11 | add3 = add1 12 | 13 | let a1 = add3(1, 2) 14 | let a2 = add1(1) 15 | let a3 = add1('1') 16 | let a4 = add1('1', '2') 17 | let a5 = add1(1, 2, 3, 4) 18 | let a6 = add1('1', '2', '3', '4') 19 | 20 | local function plus1(n) 21 | return tonumber(n) + 1 22 | end 23 | 24 | let a7 = plus1(123) 25 | let a8 = plus1('123') 26 | let a81 = plus1 '123' 27 | 28 | let a9: Function = add1 29 | let a10 = a9(123, 456, 789) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/function_type_declare.lua: -------------------------------------------------------------------------------- 1 | local function add1(a, b) 2 | return a + b 3 | end 4 | 5 | local add2 = function (a: number, b: number) 6 | return a + b 7 | end 8 | 9 | local function add3(a: number, b) 10 | return add2(a, tonumber(b)) 11 | end 12 | 13 | let add4: (number, number) => number = add2 14 | let add5: (number, number) => number = add3 15 | 16 | local function return1(a: number, b) 17 | return a, b 18 | end 19 | 20 | type Gender = { 21 | type: int, 22 | text: string 23 | } 24 | 25 | type Person = { 26 | name: string, 27 | age: int, 28 | gender: Gender, 29 | add: (number, number) => number 30 | } 31 | 32 | let p1: Person = {} 33 | p1.gender = {} 34 | p1.gender.type = 1 35 | p1.add = add4 36 | p1.add = add3 -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/generic_type.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int 5 | , fn: (number, number) => number 6 | } 7 | 8 | type Contract2 = { 9 | id: string, 10 | name: string, 11 | storage: S, 12 | sayHi: (int) => S 13 | } 14 | 15 | type G1 = { 16 | a: T1, 17 | b: T2, 18 | c: T3 19 | } 20 | 21 | type G2 = G1 > 22 | 23 | type G3 = G2 24 | 25 | let r1: G2 = {} 26 | 27 | let r2: G2 = G2() 28 | 29 | let t2 : Person = {name="hello", age=20} 30 | 31 | --t2.fn = function(a: number, b: number) 32 | -- return a + b 33 | --end 34 | 35 | let r3: G1 = {} 36 | 37 | pprint(t2.name) 38 | pprint(t2.not_found) 39 | pprint(t2['not_found2']) 40 | 41 | t2.age = t2['age'] + 1 -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/let_var.lua: -------------------------------------------------------------------------------- 1 | pprint("let_var\n") 2 | local a = 1 3 | let b = "123" 4 | var c = true 5 | 6 | var a1:int , b1:int ,c1:number = 6, 3 7 | a = 1 8 | b = 1 9 | c = 1 10 | pprint("let_var\n") 11 | 12 | var a1: int -- duplicate variable declaration 13 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/nested_function_define.lua: -------------------------------------------------------------------------------- 1 | function f1(a: number, b: number) 2 | local function f2(a: string, b: string) 3 | let a1: string = a 4 | let b1: number = b 5 | end 6 | let a1: number = a 7 | let b1: string = b 8 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/nested_record.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int, 5 | fn: (number, number) => number 6 | } 7 | 8 | type C2 = { 9 | id: string, 10 | name: string, 11 | storage: S, 12 | sayHi: (int) => S 13 | } 14 | 15 | type G1 = { 16 | a: T1, 17 | b: T2, 18 | c: T3 19 | } 20 | 21 | type G2 = G1 > 22 | 23 | type G3 = G2 24 | 25 | let M: C2 = {} 26 | 27 | let storage: Person = M.storage 28 | let age: int = storage.age 29 | let not_found = storage.not_found 30 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/record_table_parse.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | name: string, 3 | age: int 4 | } 5 | 6 | type Person2 = { 7 | id: string 8 | } 9 | 10 | let p1: Person = {name="hello", age=100} 11 | let p2: table = p1 12 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/return_union_type.lua: -------------------------------------------------------------------------------- 1 | function f1(a: number, b: string) 2 | if a > 100 then 3 | return a 4 | else 5 | return b 6 | end 7 | end 8 | 9 | let a = f1(100, 'abc') 10 | let b: number = f1(100, 'abc') -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/self_type.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int, 5 | fn: (number, number) => number 6 | } 7 | 8 | type PersonWithoutFn = { 9 | id: string, 10 | name: string, 11 | age: int 12 | } 13 | 14 | let M: Contract = {} 15 | 16 | function M:init() 17 | 18 | end 19 | 20 | function M:func1() 21 | let id: string = self.id 22 | let name: string = self.name 23 | let storage: PersonWithoutFn = self.storage 24 | let age: int = storage.age 25 | let func2 = self.func2 26 | end 27 | 28 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/simple_record.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int, 5 | age2 ?: number default 1, 6 | age3: int = 24, 7 | fn: (number, number) => number 8 | } 9 | 10 | type Contract3 = { 11 | id: string, 12 | name: string, 13 | storage: Person 14 | } 15 | 16 | type Contract2 = { 17 | id: string, 18 | name: string, 19 | storage: S, 20 | sayHi: (int) => S 21 | } 22 | 23 | type G1 = { 24 | a: T1, 25 | b: T2, 26 | c: T3 27 | } 28 | 29 | local r1: Contract2 = {} 30 | 31 | let t2 : Person = {name="hello", age=20} 32 | 33 | t2.fn = function(a: number, b: number) 34 | return a + b 35 | end 36 | 37 | let r3: G1 = {} 38 | 39 | pprint(t2.name) 40 | pprint(t2.not_found) 41 | pprint(t2['not_found2']) 42 | 43 | t2.age = t2['age'] + 1 44 | 45 | let as3 = Contract2 {a=1, b="hi"} 46 | pprint('as3', as3) 47 | let as4: Array = Array ([ 1, 2, 3, 4 ]) 48 | let as5 = Person {name="glua"} 49 | pprint('as5', as5) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_api_return.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | pprint("test api return contract init called") 7 | end 8 | 9 | function M:start() 10 | -- print(123) 11 | return 'hello' 12 | end 13 | 14 | return M 15 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_array_fetch.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:start() 10 | var a: Array = [1,2,3] 11 | let n:int = a[1] 12 | print(n) 13 | end 14 | 15 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_break.glua: -------------------------------------------------------------------------------- 1 | var a = 1 2 | while a < 10 do 3 | a = a + 1 4 | print(a) 5 | if a > 7 then 6 | break 7 | end 8 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_calculate.glua: -------------------------------------------------------------------------------- 1 | 2 | let num001 = 1 + 2 * (3) 3 | 4 | let num002 = (1) + 2 5 | 6 | let num003 = (123) 7 | 8 | let num004 = 1 + (2*3) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_call_contract_it_self.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:start() 10 | self.init(self) 11 | end 12 | 13 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_change_contract_id.glua: -------------------------------------------------------------------------------- 1 | type S = {} 2 | var M = Contract() 3 | 4 | function M:init() 5 | 6 | end 7 | 8 | function M:start() 9 | self.id = 'abc' 10 | self['name'] = 'hello' 11 | end 12 | 13 | return M 14 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_contract_return_wrong_type.glua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.init(self) 4 | 5 | end 6 | 7 | function M:start() 8 | 9 | end 10 | 11 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_contract_storage_property_type.glua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | name: string, 3 | age: int, 4 | error: int | string 5 | } 6 | 7 | var M = Contract() 8 | 9 | function M:init() 10 | 11 | end 12 | 13 | function M:start() 14 | 15 | end 16 | 17 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_control_scopes.glua: -------------------------------------------------------------------------------- 1 | var a = 1 2 | 3 | do 4 | var a = 'hello' 5 | pprint(a) 6 | end 7 | 8 | pprint(a) 9 | 10 | while a < 10 do 11 | a = a + 1 12 | end 13 | 14 | pprint(a) 15 | 16 | repeat 17 | a = a + 1 18 | until a > 20 19 | 20 | pprint(a) 21 | 22 | if true then 23 | pprint('hello if') 24 | elseif true then 25 | pprint('hello elseif') 26 | else 27 | pprint('hello if end') 28 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_correct_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:start(a: string) 6 | 7 | end 8 | 9 | function M:init() 10 | self:start('hi') 11 | end 12 | 13 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_define_contract_api_using_dot.glua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | } 3 | 4 | let M = Contract() 5 | 6 | function M:init() 7 | end 8 | 9 | function M.start(self) 10 | 11 | end 12 | 13 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_define_global_in_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function hello() 10 | a = 123 11 | end 12 | 13 | function M:start() 14 | 15 | end 16 | 17 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_deny_call_special_apis.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:on_deposit(n: int) 10 | 11 | end 12 | 13 | function M:on_destroy() 14 | 15 | end 16 | 17 | function M:on_upgrade() 18 | 19 | end 20 | 21 | function M:hello1(arg: string) 22 | pprint('hello', arg) 23 | end 24 | 25 | function M:hello(arg: string) 26 | self:init() 27 | self:on_deposit(123) 28 | self:on_destroy() 29 | self:on_upgrade() 30 | self:hello1(arg) 31 | end 32 | 33 | return M 34 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_echo_http_server.lua: -------------------------------------------------------------------------------- 1 | let http = require 'http' 2 | let net = require 'net' 3 | 4 | let res = http.request('GET', "http://www.gov.cn/", '', { 5 | Accept="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", 6 | ["User-Agent"]="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" 7 | }) 8 | pprint(http.get_res_header(res, "Content-Length")) 9 | pprint(http.get_res_body(res)) 10 | http.close(res) 11 | 12 | let server = http.listen("0.0.0.0", 3000) 13 | 14 | pprint("listening on 0.0.0.0:3000\n") 15 | 16 | -- async api 17 | 18 | let function handler(ctx) 19 | let net = require 'net' 20 | pprint("got new connection", ctx) 21 | -- pprint('get req body', http.get_req_body(ctx), '\n') 22 | net.write(ctx, "HTTP/1.1 200 OK\r\nContent-Type:text/html; utf-8\r\nContent-Length:5\r\n\r\nhello") 23 | net.close_socket(ctx) 24 | end 25 | 26 | http.accept_async(server, handler) 27 | http.start_io_loop(server) 28 | 29 | pprint("starting sync http server") 30 | 31 | while true do 32 | let ctx = http.accept(server) 33 | pprint('get req body', http.get_req_body(ctx), '\n') 34 | http.write_res_body(ctx, "hello world") 35 | http.set_status(ctx, 200, 'OK') 36 | http.set_res_header(ctx, "Content-Type", "text/html; utf-8") 37 | http.finish_res(ctx) 38 | http.close(ctx) 39 | end 40 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_emit_events.glua: -------------------------------------------------------------------------------- 1 | emit hello("world") 2 | 3 | var a = 'world' 4 | var b = 1 5 | 6 | emit hello(a) 7 | 8 | emit hello2(b) 9 | 10 | emit hello3(123) 11 | 12 | emit hello3 ("a" .. "b") -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_for_variable1.glua: -------------------------------------------------------------------------------- 1 | var users: Map = {} 2 | 3 | var user_info = {} 4 | 5 | for user: string,amount: int in pairs(user_info) do 6 | var t_user_info = totable(json.loads(users[user])) 7 | end 8 | 9 | var b = [1,2,3] 10 | 11 | for i = 1,b,2 do 12 | pprint(i) 13 | end 14 | 15 | for i = 1,5,2 do 16 | pprint(i) 17 | end 18 | 19 | var int_array = [2,3,4] 20 | 21 | for k: string, v in ipairs(int_array) do 22 | var a = v + 1 23 | var b = k .. 'error' 24 | end 25 | 26 | for k in user_info do 27 | pprint(k) 28 | end 29 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_function_type_up.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | let function add(a: number, b: number) 10 | return a + b 11 | end 12 | let add2: Function = add 13 | let r = add2('abc') 14 | 15 | function M:print() 16 | 17 | end 18 | 19 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_goto.glua: -------------------------------------------------------------------------------- 1 | var i = 0 2 | ::s1:: 3 | do 4 | print(i) 5 | i = i+1 6 | end 7 | if i>3 then 8 | goto end_of_file 9 | end 10 | 11 | goto s1 12 | 13 | ::end_of_file:: 14 | print("this is end") -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_if_stat.glua: -------------------------------------------------------------------------------- 1 | if true then 2 | pprint(1) 3 | elseif 2 then 4 | pprint(2) 5 | elseif 3 then 6 | pprint(3) 7 | else 8 | pprint(4) 9 | end 10 | 11 | if 1 then 12 | pprint(1) 13 | if 2 then 14 | pprint(2.2) 15 | end 16 | else 17 | pprint(3) 18 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_import_contract.lua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | name: string 3 | } 4 | 5 | let M: Contract = {} 6 | 7 | function M:init() 8 | 9 | end 10 | 11 | let function abc() 12 | return 123 13 | end 14 | 15 | pprint(abc()) 16 | 17 | function M:start() 18 | let demo = import_contract('demo2') 19 | demo:init() 20 | demo.start(demo) 21 | demo:start() 22 | let a = demo.storage.name 23 | let b = demo.a.b.c:hello(1,2,3) 24 | let demo2 = import_contract 'not_found' 25 | let demo3 = import_contract("not_found2") 26 | end 27 | 28 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_import_correct_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:start() 10 | pprint("start called") 11 | let demo2 = import_contract 'demo2' 12 | pprint("import contract demo2", demo2) 13 | pprint(getmetatable(totable(demo2))) 14 | let start = demo2.start 15 | demo2:start('abc') 16 | pprint("import correct contract start end") 17 | end 18 | 19 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_inner_module_type_info.glua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/test_inner_module_type_info.glua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_int_number_parse.glua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/test_int_number_parse.glua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_missing_end.glua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/test_missing_end.glua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_missing_record_colon.glua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/test_missing_record_colon.glua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_multi_lines_lambda.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:start() 10 | let a = (b: number, c: number) => do 11 | print("hello") 12 | return b+c 13 | print(b+c) 14 | end 15 | var d = a(1, 2) 16 | end 17 | 18 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_multiline_comment_and_string.glua: -------------------------------------------------------------------------------- 1 | var a = [[hello 2 | world]] 3 | 4 | --[[ 5 | this is a comment 6 | ]] 7 | 8 | var b = a 9 | pprint(b) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_new_array_and_map_type.glua: -------------------------------------------------------------------------------- 1 | let a: Array = [1,2,3] 2 | 3 | type Person = { 4 | name: string, 5 | age: int, 6 | parents: Map 7 | } 8 | 9 | type SPerson = Person 10 | 11 | let b: Map = { a: "1", b: "abc", c: "hello" } 12 | 13 | let c = SPerson() 14 | 15 | let d = [] 16 | 17 | pprint('a', a, 'b', b, 'c', c, 'd', d) 18 | 19 | let a1: table = c 20 | let a2: table = [1,2,3] 21 | let a3: Array = [1,2,3] 22 | let a4: table = {a: 1, b: 2} 23 | let a5: Array = [] 24 | let a6: Map = {'a6key': 1, b: 2, d:5} 25 | 26 | let b1: SPerson = a1 27 | let b2: SPerson = {a: 1, b: 2} 28 | let c1: Map = a1 29 | let c2: Map = c1 30 | let d1: Array = a1 31 | let d2: Array = d1 32 | 33 | 34 | let f1: int = a3[1] 35 | let f2: string = c1.a 36 | 37 | 38 | let arr1: Array = [ 1, 2.5, 3 ] 39 | 40 | let p1 = Person() 41 | let p2 = Person({name: "glua"}) 42 | 43 | type Person2 = { 44 | name: string, 45 | age: int = 24 46 | } 47 | 48 | let p3 = Array ( [ {name: "glua"}, {name: "China", age: 10000} ] ) 49 | let p4 = Array { name: "hello", age: 100 } 50 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_over_number_limit.glua: -------------------------------------------------------------------------------- 1 | let a1 = 9223372036854775808 -- max+1 2 | let a2 = -9223372036854775809 -- min-1 3 | let a3 = 9223372036854775807 -- max 4 | let a4 = -9223372036854775808 -- min 5 | 6 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_pairs.glua: -------------------------------------------------------------------------------- 1 | let b1 = {m=234,n=123, ab=1, a=1} 2 | let b2 = [1,3,6,5] 3 | (totable(b1))[100] = 200 4 | 5 | var k: object = nil 6 | var v: object = nil 7 | 8 | var sorted_b = {} 9 | var sorted_b2 = {} 10 | for k,v in pairs(b1) do 11 | print(k) 12 | sorted_b[#sorted_b+1] = [k,v] 13 | end 14 | 15 | for k,v in pairs(b2) do 16 | print(k) 17 | sorted_b2[#sorted_b2+1] = [k,v] 18 | end 19 | 20 | t1 = tojsonstring(sorted_b) 21 | pprint(t1) 22 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_quick_storage_change.glua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | count: int 3 | } 4 | 5 | var M = Contract() 6 | 7 | function M:init() 8 | self.storage.count = 0 9 | end 10 | 11 | --[[ 12 | function M:change() 13 | self.storage.count = self.storage.count + 1 14 | pprint("count changed, ", self.storage.count) 15 | end 16 | ]] 17 | 18 | function M:start() 19 | 20 | pprint('count: ', self.storage.count) 21 | self.storage.count = self.storage.count + 1 22 | pprint("count changed, ", self.storage.count) 23 | end 24 | 25 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_record_constructor_and_call_as_func.glua: -------------------------------------------------------------------------------- 1 | type Handler = { 2 | eventName: string, 3 | __call: (string) => number default (arg: string) => 0 4 | } 5 | 6 | let h1 = Handler({eventName="glua"}) 7 | let h2: Handler = {eventName="glua"} 8 | 9 | let function handler_fn(arg: string) 10 | return tonumber(arg) 11 | end 12 | 13 | h1.__call = handler_fn 14 | h2.__call = handler_fn 15 | 16 | h2('123') -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_storage_not_init_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | age: int, 3 | name: string 4 | } 5 | 6 | var M = Contract() 7 | 8 | function M:init() 9 | print("initing") 10 | end 11 | 12 | function M:start(arg: string) 13 | print("calling start api") 14 | end 15 | 16 | return M 17 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_storage_performance.glua: -------------------------------------------------------------------------------- 1 | type Storage = { 2 | -- count: int, 3 | a: int 4 | } 5 | 6 | var M = Contract() 7 | 8 | function M:init() 9 | -- self.storage.count = 100000 10 | self.storage.a = 0 11 | pprint("init test storage performance done") 12 | end 13 | 14 | function M:start() 15 | pprint("test_storage_performance start begin") 16 | var i = 0 17 | self.storage.a = 1 18 | while i < 100000 do 19 | -- self.storage.a = self.storage.a + 1 20 | var c = self.storage.a 21 | i = i + 1 22 | self.storage.a = i 23 | end 24 | pprint("i now is ", i, " and a is ", self.storage.a) 25 | pprint("test_storage_performance start end") 26 | end 27 | 28 | return M 29 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_stream_type.glua: -------------------------------------------------------------------------------- 1 | let a1 = Stream() 2 | a1:push(123) 3 | a1:push_string('abc') 4 | let s1 = a1:size() 5 | pprint("a1 size is ", s1) 6 | pprint('a1 is ', tostring(a1), tojsonstring(a1)) 7 | pprint('a1 pos is', a1:pos()) 8 | pprint("a1 to int is ", tonumber(a1)) 9 | 10 | var c: int = a1:pos() 11 | 12 | var s = '' 13 | while c < a1:size() do 14 | s = s .. tostring(a1:current()) 15 | pprint("a1[", c, "]=", a1:current()) 16 | c = c + 1 17 | a1:next() 18 | end 19 | 20 | t1 = s1 21 | t2 = s 22 | pprint(t1, t2) 23 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_table_module.glua: -------------------------------------------------------------------------------- 1 | var a = [1, 2, 3, {name='hi'}] 2 | var b = table.concat(a, ',') 3 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_table_property_function_call.glua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | name: string 3 | } 4 | 5 | var p1 = {} 6 | 7 | function p1.sayHi1(self) 8 | 9 | end 10 | 11 | function p1:sayHi2() 12 | end 13 | 14 | var p2 = Person() 15 | 16 | function p2:sayHi2() 17 | 18 | end 19 | 20 | p1.sayHi1(p1) 21 | p1:sayHi2() 22 | p2:sayHi2() 23 | p2.sayHi2(p2) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_tojsonstring.glua: -------------------------------------------------------------------------------- 1 | let a = [1, 2, 'abc', {name="hello", age=24}] 2 | let b = {m=234,n=123, ab=1} 3 | let c = [1,3,6,5] 4 | t1 = tojsonstring(a) 5 | pprint(t1) 6 | t2 = tojsonstring(b) 7 | pprint(t2) 8 | t3 = tojsonstring(c) 9 | pprint(t3) 10 | 11 | t4 = json.loads('{"avi_alp":0,"avi_asset":0,"frozen_alp":0,"alp_address":["ALPxdEoFqVnmobBg69S1rx4sy7PwBViaY6z"],"frozen_asset":0}') 12 | pprint(t4) 13 | 14 | let d = [] 15 | d[2] = 123 16 | t5 = tojsonstring(d) 17 | pprint(t5) 18 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_typed_exit_contract.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:start() 10 | pprint("test exit contract start") 11 | -- local a = 1 > 'a' 12 | exit('hello') 13 | let thinkyoung = require 'thinkyoung' 14 | thinkyoung.error("error") 15 | pprint("after exit") 16 | end 17 | 18 | pprint("test exit contract loaded") 19 | 20 | return M -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_use_keyword_as_varname.glua: -------------------------------------------------------------------------------- 1 | let return = 'abc' 2 | let end: int = 123 3 | let function do(name: string) 4 | pprint(name, 123) 5 | end 6 | 7 | let function hello(do: int) 8 | pprint(123) 9 | end 10 | 11 | var M = {} 12 | function M:end() 13 | 14 | end 15 | 16 | function M.repeat() 17 | 18 | end 19 | 20 | let function correct_func(abc: string) 21 | pprint(abc) 22 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_use_not_init_variable.glua: -------------------------------------------------------------------------------- 1 | type Storage = {} 2 | 3 | var M = Contract() 4 | 5 | function M:init() 6 | 7 | end 8 | 9 | function M:print() 10 | type man={high:int,height:int,hair:string} 11 | type person={name:string,age:int default 12,gender:man} 12 | type record={school:string default 'hkj',class:string,student:person} 13 | let b :int|record 14 | a=b() 15 | print(a.school) 16 | end 17 | 18 | return M 19 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_var_and_type_namespace.glua: -------------------------------------------------------------------------------- 1 | let a = string.split('a:b', ':') 2 | 3 | var b: string = '123' 4 | -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_wrong_new_array_and_map_type.glua: -------------------------------------------------------------------------------- 1 | let a: Array = [1,2,3] 2 | 3 | type Person = { 4 | name: string, 5 | age: int, 6 | parents: Map 7 | } 8 | 9 | type SPerson = Person 10 | 11 | let b: Map = { a: "1", b: "abc", c: "hello", 123 } 12 | 13 | let c = SPerson() 14 | 15 | let d = {a: '1', b: 2} 16 | 17 | let e = [] 18 | 19 | let f = {1,2,3} 20 | 21 | let a1: SPerson = [1,2,3] 22 | 23 | type Address = { 24 | country: string 25 | } 26 | 27 | let a2: Address = c 28 | let a3: Map = c 29 | let a4: Map = {a: 1, b: '2'} 30 | let a5: Map = a4 31 | let a6: Map = ['1','2','3'] 32 | let a7: Array = c 33 | let a8: Array = [1,'a'] 34 | let a9: Array = a8 35 | 36 | let f1: Array = [1,2,3] 37 | let f2: string = f1[1] 38 | let f3: Map = {a: '1', b: 'abc'} 39 | let f4: int = f3.a 40 | let f5: string = f3[1] 41 | 42 | let f6: Map = {} -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/test_wrong_syntax_structure1.glua: -------------------------------------------------------------------------------- 1 | function hello() 2 | let a default 123 3 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/type_parse.lua: -------------------------------------------------------------------------------- 1 | let a1 = 1 2 | let a2 = '123' 3 | let a3 = true 4 | let a4 = {} 5 | 6 | type Person = { 7 | name: string, 8 | age: int, 9 | sayHi: (number, number) => number 10 | -- ,__call: (number, number) => number 11 | } 12 | 13 | let a5: Person = {} 14 | 15 | local function add(a: number, b: number) 16 | return a + b 17 | end 18 | 19 | let a6: (number, number) => number = add 20 | a5.sayHi = a6 21 | 22 | let a7: number = tonumber(a2) 23 | let a8: table = a5 24 | -- let a9: number = a5(1, 2) 25 | let a10: string = tostring(a5) 26 | 27 | -- let a11 = a5(1) -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/typedef_and_partial.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int 5 | , fn: (number, number) => number 6 | } 7 | 8 | type Contract2 = { 9 | id: string, 10 | name: string, 11 | storage: S, 12 | sayHi: (int) => S 13 | } 14 | 15 | type G1 = { 16 | a: T1, 17 | b: T2, 18 | c: T3 19 | } 20 | 21 | type G2 = G1 > 22 | 23 | type G3 = G2 24 | 25 | type G4 = G1 26 | 27 | type G5 = G1 28 | 29 | type G6 = G1 30 | 31 | type G7 = string 32 | 33 | type G8 = G3 34 | 35 | type G9 = { 36 | a: T 37 | } -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/un_op_run_error1.lua: -------------------------------------------------------------------------------- 1 | let a = nil 2 | let b = #a -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/un_op_run_error2.lua: -------------------------------------------------------------------------------- 1 | let a = #nil -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/unicode.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/tests_typed/unicode.lua -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/variable_scope.lua: -------------------------------------------------------------------------------- 1 | local function f1() 2 | let a1: number = 1 3 | let b1: string = '123' 4 | local function f2() 5 | let c1: number = a1 6 | let a1: string = '123' 7 | let a2: string = a1 8 | let b1: number = 123 9 | end 10 | let c1: string = b1 11 | end -------------------------------------------------------------------------------- /Chain/libraries/glua/tests_typed/visit_prop.lua: -------------------------------------------------------------------------------- 1 | type Person = { 2 | id: string, 3 | name: string, 4 | age: int, 5 | is_admin: bool, 6 | fn: (number, number) => number 7 | } 8 | 9 | local function add(a: number, b: number) 10 | return a + b 11 | end 12 | 13 | let p1: Person = { 14 | name = "test", age=100, id='test', is_admin=true, fn=add 15 | } 16 | 17 | let id: string = p1.id 18 | let name: string = p1.name 19 | let age: number = p1['age'] 20 | let is_admin: bool = p1.is_admin 21 | let not_found = p1.not_found 22 | let not_found2 = p1['not_found2'] 23 | let fn: (number, number) => number = p1.fn 24 | 25 | let as3 = {} 26 | 27 | as3[p1] 28 | 29 | type Array2 = { 30 | __len: () => int, 31 | __index: (int) => T 32 | } 33 | 34 | type artT = Array2 35 | let ar1: artT = artT() 36 | 37 | let ar2: string = ar1[1] 38 | let ar3 = p1[1] 39 | 40 | let tbl1 = {} 41 | let tbl1_prop1 = tbl1.name 42 | let tbl1_prop2 = tbl1['name'] 43 | let tbl1_key1 = 'name' 44 | let tbl1_prop3 = tbl1[tbl1_key1] 45 | var tbl1_key2 = nil 46 | tbl1[tbl1_key2] = 'hello' 47 | -------------------------------------------------------------------------------- /Chain/libraries/glua/thinkyoung_lua_api.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/glua/thinkyoung_lua_api.cpp -------------------------------------------------------------------------------- /Chain/libraries/glua/thinkyoung_lua_modules/.gitignore: -------------------------------------------------------------------------------- 1 | /goopal_contract_demo2 2 | / -------------------------------------------------------------------------------- /Chain/libraries/glua/thinkyoung_lua_modules/thinkyoung_contract_contract_transfer_demo.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | 4 | function M:init() 5 | print("test contract transfer init") 6 | end 7 | 8 | function M:start() 9 | print("test contract transfer start") 10 | transfer_from_contract_to_address('A', 'ALP', 50) 11 | return 123 12 | end 13 | 14 | return M 15 | -------------------------------------------------------------------------------- /Chain/libraries/glua/thinkyoung_lua_modules/thinkyoung_contract_demo1.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.init() 4 | print('contract demo init') 5 | end 6 | 7 | function M.start() 8 | print('contract demo start') 9 | end 10 | 11 | return M -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/AssertException.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_ASSERTEXCEPTION_H 2 | #define UNITTEST_ASSERTEXCEPTION_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_EXCEPTIONS 6 | 7 | #include "HelperMacros.h" 8 | #include 9 | 10 | namespace UnitTest { 11 | 12 | class UNITTEST_LINKAGE AssertException : public std::exception 13 | { 14 | public: 15 | AssertException(); 16 | virtual ~AssertException() throw(); 17 | }; 18 | 19 | } 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/CompositeTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_COMPOSITETESTREPORTER_H 2 | #define UNITTEST_COMPOSITETESTREPORTER_H 3 | 4 | #include "TestReporter.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE CompositeTestReporter : public TestReporter 9 | { 10 | public: 11 | CompositeTestReporter(); 12 | 13 | int GetReporterCount() const; 14 | bool AddReporter(TestReporter* reporter); 15 | bool RemoveReporter(TestReporter* reporter); 16 | 17 | virtual void ReportTestStart(TestDetails const& test); 18 | virtual void ReportFailure(TestDetails const& test, char const* failure); 19 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); 20 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 21 | 22 | private: 23 | enum { kMaxReporters = 16 }; 24 | TestReporter* m_reporters[kMaxReporters]; 25 | int m_reporterCount; 26 | 27 | // revoked 28 | CompositeTestReporter(const CompositeTestReporter&); 29 | CompositeTestReporter& operator =(const CompositeTestReporter&); 30 | }; 31 | 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/CurrentTest.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_CURRENTTESTRESULTS_H 2 | #define UNITTEST_CURRENTTESTRESULTS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestResults; 9 | class TestDetails; 10 | 11 | namespace CurrentTest 12 | { 13 | UNITTEST_LINKAGE TestResults*& Results(); 14 | UNITTEST_LINKAGE const TestDetails*& Details(); 15 | } 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/DeferredTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_DEFERREDTESTREPORTER_H 2 | #define UNITTEST_DEFERREDTESTREPORTER_H 3 | 4 | #include "Config.h" 5 | 6 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 7 | 8 | #include "TestReporter.h" 9 | #include "DeferredTestResult.h" 10 | 11 | #include 12 | 13 | UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestResult); 14 | 15 | namespace UnitTest 16 | { 17 | 18 | class UNITTEST_LINKAGE DeferredTestReporter : public TestReporter 19 | { 20 | public: 21 | virtual void ReportTestStart(TestDetails const& details); 22 | virtual void ReportFailure(TestDetails const& details, char const* failure); 23 | virtual void ReportTestFinish(TestDetails const& details, float secondsElapsed); 24 | 25 | typedef std::vector< DeferredTestResult > DeferredTestResultList; 26 | DeferredTestResultList& GetResults(); 27 | 28 | private: 29 | DeferredTestResultList m_results; 30 | }; 31 | 32 | } 33 | 34 | #endif 35 | #endif 36 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/DeferredTestResult.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_DEFERREDTESTRESULT_H 2 | #define UNITTEST_DEFERREDTESTRESULT_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 6 | 7 | #include "HelperMacros.h" 8 | #include 9 | #include 10 | 11 | namespace UnitTest 12 | { 13 | 14 | class UNITTEST_LINKAGE DeferredTestFailure 15 | { 16 | public: 17 | DeferredTestFailure(); 18 | DeferredTestFailure(int lineNumber_, const char* failureStr_); 19 | 20 | int lineNumber; 21 | char failureStr[1024]; 22 | }; 23 | 24 | } 25 | 26 | UNITTEST_STDVECTOR_LINKAGE(UnitTest::DeferredTestFailure); 27 | 28 | namespace UnitTest 29 | { 30 | 31 | class UNITTEST_LINKAGE DeferredTestResult 32 | { 33 | public: 34 | DeferredTestResult(); 35 | DeferredTestResult(char const* suite, char const* test); 36 | ~DeferredTestResult(); 37 | 38 | std::string suiteName; 39 | std::string testName; 40 | std::string failureFile; 41 | 42 | typedef std::vector< DeferredTestFailure > FailureVec; 43 | FailureVec failures; 44 | 45 | float timeElapsed; 46 | bool failed; 47 | }; 48 | 49 | } 50 | 51 | #endif 52 | #endif 53 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/ExceptionMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_EXCEPTIONMACROS_H 2 | #define UNITTEST_EXCEPTIONMACROS_H 3 | 4 | #include "Config.h" 5 | 6 | #ifndef UNITTEST_NO_EXCEPTIONS 7 | #define UT_TRY(x) try x 8 | #define UT_THROW(x) throw x 9 | #define UT_RETHROW(ExceptionType) catch(ExceptionType&) { throw; } 10 | #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) catch(ExceptionType& ExceptionName) CatchBody 11 | #define UT_CATCH_ALL(CatchBody) catch(...) CatchBody 12 | #else 13 | #define UT_TRY(x) x 14 | #define UT_THROW(x) 15 | #define UT_RETHROW(ExceptionType) 16 | #define UT_CATCH(ExceptionType, ExceptionName, CatchBody) 17 | #define UT_CATCH_ALL(CatchBody) 18 | #endif 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/Posix/SignalTranslator.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_SIGNALTRANSLATOR_H 2 | #define UNITTEST_SIGNALTRANSLATOR_H 3 | 4 | #include 5 | #include 6 | 7 | namespace UnitTest { 8 | 9 | class SignalTranslator 10 | { 11 | public: 12 | SignalTranslator(); 13 | ~SignalTranslator(); 14 | 15 | static sigjmp_buf* s_jumpTarget; 16 | 17 | private: 18 | sigjmp_buf m_currentJumpTarget; 19 | sigjmp_buf* m_oldJumpTarget; 20 | 21 | struct sigaction m_old_SIGFPE_action; 22 | struct sigaction m_old_SIGTRAP_action; 23 | struct sigaction m_old_SIGSEGV_action; 24 | struct sigaction m_old_SIGBUS_action; 25 | struct sigaction m_old_SIGABRT_action; 26 | struct sigaction m_old_SIGALRM_action; 27 | }; 28 | 29 | #if !defined (__GNUC__) 30 | #define UNITTEST_EXTENSION 31 | #else 32 | #define UNITTEST_EXTENSION __extension__ 33 | #endif 34 | 35 | #define UNITTEST_THROW_SIGNALS_POSIX_ONLY \ 36 | UnitTest::SignalTranslator sig; \ 37 | if (UNITTEST_EXTENSION sigsetjmp(*UnitTest::SignalTranslator::s_jumpTarget, 1) != 0) \ 38 | throw ("Unhandled system exception"); 39 | 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/Posix/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMEHELPERS_H 2 | #define UNITTEST_TIMEHELPERS_H 3 | 4 | #include 5 | 6 | namespace UnitTest { 7 | 8 | class Timer 9 | { 10 | public: 11 | Timer(); 12 | void Start(); 13 | double GetTimeInMs() const; 14 | 15 | private: 16 | struct timeval m_startTime; 17 | }; 18 | 19 | 20 | namespace TimeHelpers 21 | { 22 | void SleepMs(int ms); 23 | } 24 | 25 | 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/ReportAssert.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_ASSERT_H 2 | #define UNITTEST_ASSERT_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | UNITTEST_LINKAGE void ReportAssert(char const* description, char const* filename, int lineNumber); 9 | 10 | } 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/ReportAssertImpl.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_REPORTASSERTIMPL_H 2 | #define UNITTEST_REPORTASSERTIMPL_H 3 | 4 | #include "Config.h" 5 | #include "HelperMacros.h" 6 | 7 | #ifdef UNITTEST_NO_EXCEPTIONS 8 | #include 9 | #endif 10 | 11 | namespace UnitTest { 12 | 13 | class TestResults; 14 | class TestDetails; 15 | 16 | namespace Detail { 17 | 18 | UNITTEST_LINKAGE void ExpectAssert(bool expected); 19 | 20 | UNITTEST_LINKAGE void ReportAssertEx(TestResults* testResults, 21 | const TestDetails* testDetails, 22 | char const* description, 23 | char const* filename, 24 | int lineNumber); 25 | 26 | UNITTEST_LINKAGE bool AssertExpected(); 27 | 28 | #ifdef UNITTEST_NO_EXCEPTIONS 29 | UNITTEST_LINKAGE UNITTEST_JMPBUF* GetAssertJmpBuf(); 30 | 31 | #ifdef UNITTEST_WIN32 32 | #define UNITTEST_SET_ASSERT_JUMP_TARGET() \ 33 | __pragma(warning(push)) __pragma(warning(disable: 4611)) \ 34 | UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) \ 35 | __pragma(warning(pop)) 36 | #else 37 | #define UNITTEST_SET_ASSERT_JUMP_TARGET() UNITTEST_SETJMP(*UnitTest::Detail::GetAssertJmpBuf()) 38 | #endif 39 | 40 | #define UNITTEST_JUMP_TO_ASSERT_JUMP_TARGET() UNITTEST_LONGJMP(*UnitTest::Detail::GetAssertJmpBuf(), 1) 41 | #endif 42 | 43 | } 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/RequireMacros.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_REQUIREMACROS_H 2 | #define UNITTEST_REQUIREMACROS_H 3 | 4 | #include "RequiredCheckTestReporter.h" 5 | 6 | #ifdef REQUIRE 7 | #error UnitTest++ redefines REQUIRE 8 | #endif 9 | 10 | #define REQUIRE for(UnitTest::RequiredCheckTestReporter decoratedReporter(*UnitTest::CurrentTest::Results()); decoratedReporter.Next(); ) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/RequiredCheckException.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_REQUIREDCHECKEXCEPTION_H 2 | #define UNITTEST_REQUIREDCHECKEXCEPTION_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_EXCEPTIONS 6 | 7 | #include "HelperMacros.h" 8 | #include 9 | 10 | namespace UnitTest { 11 | 12 | class UNITTEST_LINKAGE RequiredCheckException : public std::exception 13 | { 14 | public: 15 | RequiredCheckException(); 16 | virtual ~RequiredCheckException() throw(); 17 | }; 18 | 19 | } 20 | 21 | #endif 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/RequiredCheckTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H 2 | #define UNITTEST_REQUIRED_CHECK_TEST_REPORTER_H 3 | 4 | #include "HelperMacros.h" 5 | #include "ThrowingTestReporter.h" 6 | 7 | namespace UnitTest { 8 | 9 | class TestResults; 10 | 11 | // This RAII class decorates the current TestReporter with 12 | // a version that throws after reporting a failure. 13 | class UNITTEST_LINKAGE RequiredCheckTestReporter 14 | { 15 | public: 16 | explicit RequiredCheckTestReporter(TestResults& results); 17 | ~RequiredCheckTestReporter(); 18 | 19 | bool Next(); 20 | 21 | private: 22 | TestResults& m_results; 23 | TestReporter* m_originalTestReporter; 24 | ThrowingTestReporter m_throwingReporter; 25 | int m_continue; 26 | }; 27 | } 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/Test.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TEST_H 2 | #define UNITTEST_TEST_H 3 | 4 | #include "TestDetails.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestResults; 9 | class TestList; 10 | 11 | class UNITTEST_LINKAGE Test 12 | { 13 | public: 14 | explicit Test(char const* testName, char const* suiteName = "DefaultSuite", char const* filename = "", int lineNumber = 0); 15 | virtual ~Test(); 16 | void Run(); 17 | 18 | TestDetails const m_details; 19 | Test* m_nextTest; 20 | 21 | mutable bool m_isMockTest; 22 | 23 | static TestList& GetTestList(); 24 | 25 | virtual void RunImpl() const; 26 | 27 | private: 28 | Test(Test const&); 29 | Test& operator =(Test const&); 30 | }; 31 | 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestDetails.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTDETAILS_H 2 | #define UNITTEST_TESTDETAILS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE TestDetails 9 | { 10 | public: 11 | TestDetails(char const* testName, char const* suiteName, char const* filename, int lineNumber); 12 | TestDetails(const TestDetails& details, int lineNumber); 13 | 14 | char const* const suiteName; 15 | char const* const testName; 16 | char const* const filename; 17 | int const lineNumber; 18 | mutable bool timeConstraintExempt; 19 | 20 | TestDetails(TestDetails const&); // Why is it public? --> http://gcc.gnu.org/bugs.html#cxx_rvalbind 21 | private: 22 | TestDetails& operator=(TestDetails const&); 23 | }; 24 | 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestList.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTLIST_H 2 | #define UNITTEST_TESTLIST_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class Test; 9 | 10 | class UNITTEST_LINKAGE TestList 11 | { 12 | public: 13 | TestList(); 14 | void Add (Test* test); 15 | 16 | Test* GetHead() const; 17 | 18 | private: 19 | Test* m_head; 20 | Test* m_tail; 21 | }; 22 | 23 | 24 | class UNITTEST_LINKAGE ListAdder 25 | { 26 | public: 27 | ListAdder(TestList& list, Test* test); 28 | }; 29 | 30 | } 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTREPORTER_H 2 | #define UNITTEST_TESTREPORTER_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class TestDetails; 9 | 10 | class UNITTEST_LINKAGE TestReporter 11 | { 12 | public: 13 | virtual ~TestReporter(); 14 | 15 | virtual void ReportTestStart(TestDetails const& test) = 0; 16 | virtual void ReportFailure(TestDetails const& test, char const* failure) = 0; 17 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed) = 0; 18 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed) = 0; 19 | }; 20 | 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestReporterStdout.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTREPORTERSTDOUT_H 2 | #define UNITTEST_TESTREPORTERSTDOUT_H 3 | 4 | #include "TestReporter.h" 5 | 6 | namespace UnitTest { 7 | 8 | class UNITTEST_LINKAGE TestReporterStdout : public TestReporter 9 | { 10 | private: 11 | virtual void ReportTestStart(TestDetails const& test); 12 | virtual void ReportFailure(TestDetails const& test, char const* failure); 13 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); 14 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 15 | }; 16 | 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestResults.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTRESULTS_H 2 | #define UNITTEST_TESTRESULTS_H 3 | 4 | #include "HelperMacros.h" 5 | 6 | namespace UnitTest { 7 | 8 | class RequiredCheckTestReporter; 9 | class TestReporter; 10 | class TestDetails; 11 | 12 | class UNITTEST_LINKAGE TestResults 13 | { 14 | public: 15 | explicit TestResults(TestReporter* reporter = 0); 16 | 17 | void OnTestStart(TestDetails const& test); 18 | void OnTestFailure(TestDetails const& test, char const* failure); 19 | void OnTestFinish(TestDetails const& test, float secondsElapsed); 20 | 21 | int GetTotalTestCount() const; 22 | int GetFailedTestCount() const; 23 | int GetFailureCount() const; 24 | 25 | private: 26 | friend class RequiredCheckTestReporter; 27 | 28 | TestReporter* m_testReporter; 29 | int m_totalTestCount; 30 | int m_failedTestCount; 31 | int m_failureCount; 32 | 33 | bool m_currentTestFailed; 34 | 35 | TestResults(TestResults const&); 36 | TestResults& operator =(TestResults const&); 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestRunner.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTRUNNER_H 2 | #define UNITTEST_TESTRUNNER_H 3 | 4 | #include "Test.h" 5 | #include "TestList.h" 6 | #include "CurrentTest.h" 7 | 8 | namespace UnitTest { 9 | 10 | class TestReporter; 11 | class TestResults; 12 | class Timer; 13 | 14 | UNITTEST_LINKAGE int RunAllTests(); 15 | 16 | struct True 17 | { 18 | bool operator()(const Test* const) const 19 | { 20 | return true; 21 | } 22 | }; 23 | 24 | class UNITTEST_LINKAGE TestRunner 25 | { 26 | public: 27 | explicit TestRunner(TestReporter& reporter); 28 | ~TestRunner(); 29 | 30 | template< class Predicate > 31 | int RunTestsIf(TestList const& list, char const* suiteName, 32 | const Predicate& predicate, int maxTestTimeInMs) const 33 | { 34 | Test* curTest = list.GetHead(); 35 | 36 | while (curTest != 0) 37 | { 38 | if (IsTestInSuite(curTest, suiteName) && predicate(curTest)) 39 | RunTest(m_result, curTest, maxTestTimeInMs); 40 | 41 | curTest = curTest->m_nextTest; 42 | } 43 | 44 | return Finish(); 45 | } 46 | 47 | TestResults* GetTestResults(); 48 | 49 | private: 50 | TestReporter* m_reporter; 51 | TestResults* m_result; 52 | Timer* m_timer; 53 | 54 | int Finish() const; 55 | bool IsTestInSuite(const Test* const curTest, char const* suiteName) const; 56 | void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const; 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TestSuite.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TESTSUITE_H 2 | #define UNITTEST_TESTSUITE_H 3 | 4 | namespace UnitTestSuite 5 | { 6 | inline char const* GetSuiteName () 7 | { 8 | return "DefaultSuite"; 9 | } 10 | } 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/ThrowingTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_THROWINGTESTREPORTER_H 2 | #define UNITTEST_THROWINGTESTREPORTER_H 3 | 4 | #include "TestReporter.h" 5 | 6 | namespace UnitTest { 7 | 8 | // A TestReporter that throws when ReportFailure is called. Otherwise it 9 | // forwards the calls to a decorated TestReporter 10 | class ThrowingTestReporter : public TestReporter 11 | { 12 | public: 13 | explicit ThrowingTestReporter(TestReporter* reporter); 14 | 15 | virtual ~ThrowingTestReporter(); 16 | virtual void ReportTestStart(TestDetails const& test); 17 | virtual void ReportFailure(TestDetails const& test, char const* failure); 18 | virtual void ReportTestFinish(TestDetails const& test, float secondsElapsed); 19 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 20 | 21 | private: 22 | TestReporter* m_decoratedReporter; 23 | }; 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TimeConstraint.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMECONSTRAINT_H 2 | #define UNITTEST_TIMECONSTRAINT_H 3 | 4 | #include "TimeHelpers.h" 5 | #include "HelperMacros.h" 6 | #include "TestDetails.h" 7 | 8 | namespace UnitTest { 9 | 10 | class TestResults; 11 | 12 | class UNITTEST_LINKAGE TimeConstraint 13 | { 14 | public: 15 | TimeConstraint(int ms, TestDetails const& details, int lineNumber); 16 | ~TimeConstraint(); 17 | 18 | private: 19 | void operator=(TimeConstraint const&); 20 | TimeConstraint(TimeConstraint const&); 21 | 22 | Timer m_timer; 23 | TestDetails const m_details; 24 | int const m_maxMs; 25 | }; 26 | 27 | #define UNITTEST_TIME_CONSTRAINT(ms) \ 28 | UnitTest::TimeConstraint unitTest__timeConstraint__(ms, m_details, __LINE__) 29 | 30 | #define UNITTEST_TIME_CONSTRAINT_EXEMPT() \ 31 | UNITTEST_MULTILINE_MACRO_BEGIN \ 32 | m_details.timeConstraintExempt = true; \ 33 | UNITTEST_MULTILINE_MACRO_END 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | 3 | #if defined UNITTEST_POSIX 4 | #include "Posix/TimeHelpers.h" 5 | #else 6 | #include "Win32/TimeHelpers.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/UnitTest++.h: -------------------------------------------------------------------------------- 1 | #include "UnitTestPP.h" -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/UnitTestPP.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTESTPP_H 2 | #define UNITTESTPP_H 3 | 4 | /* 5 | ** Windows stuff 6 | */ 7 | #if defined(_WIN32) /* { */ 8 | 9 | #if !defined(_CRT_SECURE_NO_WARNINGS) 10 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 11 | #endif 12 | 13 | #endif /* } */ 14 | 15 | #include "Config.h" 16 | #include "TestMacros.h" 17 | #include "CheckMacros.h" 18 | #include "RequireMacros.h" 19 | #include "TestRunner.h" 20 | #include "TimeConstraint.h" 21 | #include "ReportAssert.h" 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/Win32/TimeHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_TIMEHELPERS_H 2 | #define UNITTEST_TIMEHELPERS_H 3 | 4 | #include "../Config.h" 5 | #include "../HelperMacros.h" 6 | 7 | #ifdef UNITTEST_MINGW 8 | #ifndef __int64 9 | #define __int64 long long 10 | #endif 11 | #endif 12 | 13 | namespace UnitTest { 14 | 15 | class UNITTEST_LINKAGE Timer 16 | { 17 | public: 18 | Timer(); 19 | void Start(); 20 | double GetTimeInMs() const; 21 | 22 | private: 23 | __int64 GetTime() const; 24 | 25 | void* m_threadHandle; 26 | 27 | #if defined(_WIN64) 28 | unsigned __int64 m_processAffinityMask; 29 | #else 30 | unsigned long m_processAffinityMask; 31 | #endif 32 | 33 | __int64 m_startTime; 34 | __int64 m_frequency; 35 | }; 36 | 37 | 38 | namespace TimeHelpers 39 | { 40 | UNITTEST_LINKAGE void SleepMs(int ms); 41 | } 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /Chain/libraries/include/UnitTest++/XmlTestReporter.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITTEST_XMLTESTREPORTER_H 2 | #define UNITTEST_XMLTESTREPORTER_H 3 | 4 | #include "Config.h" 5 | #ifndef UNITTEST_NO_DEFERRED_REPORTER 6 | 7 | #include "DeferredTestReporter.h" 8 | 9 | #include 10 | 11 | namespace UnitTest 12 | { 13 | 14 | class UNITTEST_LINKAGE XmlTestReporter : public DeferredTestReporter 15 | { 16 | public: 17 | explicit XmlTestReporter(std::ostream& ostream); 18 | 19 | virtual void ReportSummary(int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 20 | 21 | private: 22 | XmlTestReporter(XmlTestReporter const&); 23 | XmlTestReporter& operator=(XmlTestReporter const&); 24 | 25 | void AddXmlElement(std::ostream& os, char const* encoding); 26 | void BeginResults(std::ostream& os, int totalTestCount, int failedTestCount, int failureCount, float secondsElapsed); 27 | void EndResults(std::ostream& os); 28 | void BeginTest(std::ostream& os, DeferredTestResult const& result); 29 | void AddFailure(std::ostream& os, DeferredTestResult const& result); 30 | void EndTest(std::ostream& os, DeferredTestResult const& result); 31 | 32 | std::ostream& m_ostream; 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /Chain/libraries/include/api/ConversionFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace thinkyoung { 7 | namespace api { 8 | 9 | fc::variant fc_ip_endpoint_to_variant(const fc::ip::endpoint& endpoint); 10 | fc::ip::endpoint variant_to_fc_ip_endpoint(const fc::variant& endpoint_as_variant); 11 | 12 | fc::variant time_interval_in_seconds_to_variant(const fc::microseconds time_interval); 13 | fc::microseconds variant_to_time_interval_in_seconds(const fc::variant& time_interval_as_variant); 14 | 15 | } 16 | } // end namespace thinkyoung::api 17 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Address.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/blockchain/Address.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/BlockEntry.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace blockchain { 6 | 7 | struct BlockEntry : public thinkyoung::blockchain::DigestBlock 8 | { 9 | BlockIdType id; 10 | uint64_t block_size = 0; /* Bytes */ 11 | fc::microseconds latency; /* Time between block timestamp and first push_block */ 12 | 13 | ShareType signee_shares_issued = 0; 14 | ShareType signee_fees_collected = 0; 15 | ShareType signee_fees_destroyed = 0; 16 | fc::ripemd160 random_seed; 17 | 18 | fc::microseconds processing_time; /* Time taken for extend_chain to run */ 19 | }; 20 | typedef optional oBlockEntry; 21 | 22 | } 23 | } // thinkyoung::blockchain 24 | 25 | FC_REFLECT_DERIVED(thinkyoung::blockchain::BlockEntry, 26 | (thinkyoung::blockchain::DigestBlock), 27 | (id) 28 | (block_size) 29 | (latency) 30 | (signee_shares_issued) 31 | (signee_fees_collected) 32 | (signee_fees_destroyed) 33 | (random_seed) 34 | (processing_time) 35 | ) 36 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Checkpoints.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace blockchain { 6 | namespace detail{ 7 | 8 | static std::map CHECKPOINT_BLOCKS 9 | { 10 | //{ 1246900, thinkyoung::blockchain::block_id_type( "b5214c1bc914ea5da6c1bb8f774d07f12b85dbe2" ) }, 11 | //{ 1279500, thinkyoung::blockchain::block_id_type( "488313d2c1c85bdec117bac0379f7b17f7cfbed3" ) } 12 | }; 13 | // Initialized in load_checkpoints() 14 | static uint32_t LAST_CHECKPOINT_BLOCK_NUM = 0; 15 | 16 | } 17 | } 18 | } // thinkyoung::blockchain 19 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Condition.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | namespace thinkyoung { 5 | namespace blockchain { 6 | 7 | // The difference between a condition and normal business logic is that 8 | // condition proof equivalence classes always yield the same condition 9 | // and so you can embed the proof at the right "scope" in the transaction 10 | // without doing anything complicated. 11 | // eval(with[cond](expr)) would mean: push_permission prove("with[cond](expr)"); eval(expr) 12 | 13 | struct Condition 14 | { 15 | }; 16 | struct proof 17 | { 18 | Condition get_condition(); 19 | }; 20 | 21 | struct MultisigCondition : Condition 22 | { 23 | uint32_t required; // 0 means anyone can claim. -1 means the DAC can 24 | std::set
owners; 25 | 26 | MultisigCondition() :required(-1), owners(set
()){} 27 | MultisigCondition(uint32_t m, set
owners) 28 | :required(m), owners(owners) 29 | {} 30 | }; 31 | 32 | // pow 33 | // delegate_fraud 34 | // timelock 35 | // BTC spv utxo claim 36 | // cross-chain trading 37 | // 38 | 39 | } 40 | } // thinkyoung::blockchain 41 | 42 | FC_REFLECT(thinkyoung::blockchain::Condition, BOOST_PP_SEQ_NIL); 43 | FC_REFLECT(thinkyoung::blockchain::MultisigCondition, (required)(owners)); 44 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/ContractOperations.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/blockchain/ContractOperations.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/EventOperations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "blockchain/Types.hpp" 4 | #include "blockchain/Operations.hpp" 5 | 6 | namespace thinkyoung { 7 | namespace blockchain { 8 | 9 | struct EventOperation{ 10 | static const OperationTypeEnum type; 11 | 12 | EventOperation(){} 13 | 14 | EventOperation(const ContractIdType& id, const std::string& event_type, const std::string& event_param) : id(id) 15 | { 16 | if (event_type.length() > EVENT_TYPE_MAX_LEN) 17 | this->event_type = event_type.substr(0, EVENT_TYPE_MAX_LEN); 18 | else 19 | this->event_type = event_type; 20 | this->is_truncated = false; 21 | this->event_param = event_param; 22 | 23 | if (this->event_param.length() > EVENT_PARAM_MAX_LEN) 24 | { 25 | this->is_truncated = true; 26 | this->event_param = this->event_param.substr(0, EVENT_PARAM_MAX_LEN); 27 | } 28 | } 29 | 30 | ContractIdType id; 31 | std::string event_type; 32 | std::string event_param; 33 | bool is_truncated; 34 | 35 | void evaluate(TransactionEvaluationState& eval_state)const; 36 | }; 37 | 38 | } 39 | } 40 | 41 | 42 | FC_REFLECT(thinkyoung::blockchain::EventOperation, (id)(event_type)(event_param)(is_truncated)) -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Exceptions.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/blockchain/Exceptions.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/GenesisJson.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace thinkyoung { 6 | namespace blockchain { 7 | 8 | GenesisState get_builtin_genesis_block_config(); 9 | fc::sha256 get_builtin_genesis_block_state_hash(); 10 | 11 | } 12 | } // thinkyoung::blockchain 13 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/ImessageOperations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include 6 | 7 | namespace thinkyoung { 8 | namespace blockchain { 9 | struct ImessageMemoOperation 10 | { 11 | static const OperationTypeEnum type; 12 | string imessage; 13 | ImessageMemoOperation(){} 14 | ImessageMemoOperation(std::string imess) :imessage(imess){} 15 | void evaluate(TransactionEvaluationState& eval_state)const; 16 | }; 17 | } 18 | } 19 | FC_REFLECT(thinkyoung::blockchain::ImessageMemoOperation, (imessage)) -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/SlateEntry.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace thinkyoung { 6 | namespace blockchain { 7 | 8 | struct SlateEntry; 9 | typedef optional oSlateEntry; 10 | 11 | class ChainInterface; 12 | struct SlateEntry { 13 | set slate; 14 | vector duplicate_slate; 15 | 16 | SlateIdType id()const; 17 | void sanity_check(const ChainInterface&)const; 18 | static oSlateEntry lookup(const ChainInterface&, const SlateIdType); 19 | static void store(ChainInterface&, const SlateIdType, const SlateEntry&); 20 | static void remove(ChainInterface&, const SlateIdType); 21 | }; 22 | 23 | class SlateDbInterface { 24 | friend struct SlateEntry; 25 | 26 | virtual oSlateEntry slate_lookup_by_id(const SlateIdType)const = 0; 27 | virtual void slate_insert_into_id_map(const SlateIdType, const SlateEntry&) = 0; 28 | virtual void slate_erase_from_id_map(const SlateIdType) = 0; 29 | }; 30 | 31 | } 32 | } // thinkyoung::blockchain 33 | 34 | FC_REFLECT(thinkyoung::blockchain::SlateEntry, (slate)(duplicate_slate)) 35 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/SlateOperations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace thinkyoung { 6 | namespace blockchain { 7 | 8 | struct DefineSlateOperation 9 | { 10 | static const OperationTypeEnum type; 11 | 12 | vector slate; 13 | 14 | void evaluate(TransactionEvaluationState& eval_state)const; 15 | }; 16 | 17 | } 18 | } // thinkyoung::blockchain 19 | 20 | FC_REFLECT(thinkyoung::blockchain::DefineSlateOperation, (slate)) 21 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/StorageOperations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace thinkyoung { 7 | namespace blockchain { 8 | 9 | struct StorageDataChangeType 10 | { 11 | StorageDataType storage_before; 12 | StorageDataType storage_after; 13 | }; 14 | 15 | struct StorageOperation 16 | { 17 | static const OperationTypeEnum type; 18 | 19 | StorageOperation(){} 20 | 21 | ContractIdType contract_id; 22 | std::map contract_change_storages; 23 | 24 | template 25 | void update_contract_map_storage(const StorageDataChangeType& change_storage, StorageDataType& storage)const; 26 | 27 | //void update_contract_storages(const StorageDataChangeType& change_storage, StorageDataType& storage)const; 28 | void update_contract_storages(const std::string storage_name, const StorageDataChangeType& change_storage, 29 | std::map& contract_storages)const; 30 | 31 | void evaluate(TransactionEvaluationState& eval_state)const; 32 | }; 33 | 34 | } 35 | } // thinkyoung::blockchain 36 | 37 | 38 | FC_REFLECT(thinkyoung::blockchain::StorageDataChangeType, (storage_before)(storage_after)) 39 | FC_REFLECT(thinkyoung::blockchain::StorageOperation, (contract_id)(contract_change_storages)) 40 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Time.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace thinkyoung { 8 | namespace blockchain { 9 | 10 | typedef fc::signal TimeDiscontinuitySignalType; 11 | extern TimeDiscontinuitySignalType time_discontinuity_signal; 12 | 13 | fc::optional ntp_time(); 14 | fc::time_point_sec now(); 15 | fc::time_point_sec nonblocking_now(); // identical to now() but guaranteed not to block 16 | void update_ntp_time(); 17 | fc::microseconds ntp_error(); 18 | void shutdown_ntp_time(); 19 | 20 | void start_simulated_time(const fc::time_point sim_time); 21 | void advance_time(int32_t delta_seconds); 22 | 23 | uint32_t get_slot_number(const fc::time_point_sec timestamp); 24 | fc::time_point_sec get_slot_start_time(uint32_t slot_number); 25 | fc::time_point_sec get_slot_start_time(const fc::time_point_sec timestamp); 26 | 27 | } 28 | } // thinkyoung::blockchain 29 | -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/Transaction.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/blockchain/Transaction.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/TransactionEvaluationState.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/blockchain/TransactionEvaluationState.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/TransactionOperations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace thinkyoung { 7 | namespace blockchain { 8 | 9 | struct TransactionOperation 10 | { 11 | static const OperationTypeEnum type; 12 | 13 | TransactionOperation(){} 14 | 15 | TransactionOperation(const SignedTransaction& signed_trx) 16 | :trx(signed_trx){} 17 | 18 | TransactionOperation(const TransactionOperation& trx_op) 19 | :trx(trx_op.trx){} 20 | 21 | SignedTransaction trx; 22 | 23 | void evaluate(TransactionEvaluationState& eval_state)const; 24 | }; 25 | 26 | } 27 | } // thinkyoung::blockchain 28 | 29 | 30 | FC_REFLECT(thinkyoung::blockchain::TransactionOperation, (trx)) -------------------------------------------------------------------------------- /Chain/libraries/include/blockchain/api_extern.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | namespace thinkyoung{ 4 | namespace client{ 5 | extern Client* g_client; 6 | extern bool g_client_quit; 7 | } 8 | } -------------------------------------------------------------------------------- /Chain/libraries/include/client/ApiLogger.hpp: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #if ALP_GLOBAL_API_LOG 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace thinkyoung { 13 | namespace client { 14 | 15 | class StreamApiLogger : public thinkyoung::api::ApiLogger 16 | { 17 | public: 18 | StreamApiLogger(fc::ostream_ptr output); 19 | virtual ~StreamApiLogger(); 20 | 21 | virtual void log_call_started(uint64_t call_id, const thinkyoung::api::CommonApi* target, const fc::string& name, const fc::variants& args) override; 22 | virtual void log_call_finished(uint64_t call_id, const thinkyoung::api::CommonApi* target, const fc::string& name, const fc::variants& args, const fc::variant& result) override; 23 | 24 | virtual void close(); 25 | 26 | fc::ostream_ptr output; 27 | fc::mutex output_mutex; 28 | bool is_first_item; 29 | bool is_closed; 30 | }; 31 | 32 | } 33 | } // end namespace thinkyoung::client 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /Chain/libraries/include/client/Notifier.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | namespace thinkyoung { 9 | namespace client { 10 | namespace detail { 11 | class AlpGntpNotifierImpl; 12 | } 13 | 14 | class AlpGntpNotifier { 15 | public: 16 | AlpGntpNotifier(const std::string& host_to_notify = "127.0.0.1", uint16_t port = 23053, 17 | const std::string& alp_instance_identifier = "Alp", 18 | const fc::optional& password = fc::optional()); 19 | ~AlpGntpNotifier(); 20 | 21 | void client_is_shutting_down(); 22 | void notify_connection_count_changed(uint32_t new_connection_count); 23 | void notify_client_exiting_unexpectedly(); 24 | void notify_head_block_too_old(const fc::time_point_sec head_block_age); 25 | private: 26 | std::unique_ptr my; 27 | }; 28 | typedef std::shared_ptr AlpGntpNotifierPtr; 29 | 30 | } 31 | } // end namespace thinkyoung::client 32 | -------------------------------------------------------------------------------- /Chain/libraries/include/client/SeedNodes.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace thinkyoung { 4 | namespace client { 5 | 6 | #ifndef ALP_TEST_NETWORK 7 | static const std::vector SeedNodes = { 8 | "node.achain.com:61696" 9 | }; 10 | #else 11 | static const std::vector SeedNodes { }; 12 | #endif 13 | 14 | } 15 | } // thinkyoung::client 16 | -------------------------------------------------------------------------------- /Chain/libraries/include/client/build_info.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #cmakedefine GOP_CLIENT_JENKINS_BUILD_NUMBER @GOP_CLIENT_JENKINS_BUILD_NUMBER@ 4 | #cmakedefine GOP_CLIENT_JENKINS_BUILD_URL "@GOP_CLIENT_JENKINS_BUILD_URL@" 5 | -------------------------------------------------------------------------------- /Chain/libraries/include/db/Exception.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace db { 6 | 7 | FC_DECLARE_EXCEPTION(level_map_failure, 10000, "level_map failure"); 8 | FC_DECLARE_EXCEPTION(level_map_open_failure, 10001, "level_map open failure"); 9 | 10 | FC_DECLARE_EXCEPTION(level_pod_map_failure, 11000, "level_pod_map failure"); 11 | FC_DECLARE_EXCEPTION(level_pod_map_open_failure, 11001, "level_pod_map open failure"); 12 | 13 | } 14 | } // thinkyoung::db 15 | -------------------------------------------------------------------------------- /Chain/libraries/include/db/Fwd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace db { 6 | 7 | class peer; 8 | typedef std::shared_ptr peer_ptr; 9 | 10 | class peer_ram; 11 | typedef std::shared_ptr peer_ram_ptr; 12 | 13 | } 14 | } // namespace thinkyoung::db 15 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_api_types.h: -------------------------------------------------------------------------------- 1 | #ifndef glua_api_types_h 2 | #define glua_api_types_h 3 | 4 | #include 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_astparser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/glua/glua_astparser.h -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_common.h: -------------------------------------------------------------------------------- 1 | #ifndef glua_common_h 2 | #define glua_common_h 3 | 4 | #include 5 | 6 | #ifdef _DEBUG 7 | 8 | #if defined MEMCHECK_VLD 9 | #include 10 | #include 11 | #elif defined MEMCHECK_MEMWATCH 12 | #define MEMWATCH 13 | #define MW_STDIO 14 | #include 15 | #include "memwatch.h" 16 | #endif 17 | 18 | #endif // #ifdef _DEBUG 19 | 20 | #define MACRO_STR_RAW(tok) #tok 21 | #define MACRO_STR(tok) MACRO_STR_RAW(tok) 22 | 23 | #endif // #ifndef glua_common_h 24 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_compat.h: -------------------------------------------------------------------------------- 1 | // should be included after lua*.h 2 | #ifndef glua_compat_h 3 | #define glua_compat_h 4 | 5 | #include "lua.h" 6 | 7 | #define lua_open() luaL_newstate() 8 | #define luadec_freearray(L, b, n, t) luaM_freearray(L, b, n) 9 | 10 | #define UPVAL_TYPE Upvaldesc 11 | #define NUPS(f) (f->sizeupvalues) 12 | #define UPVAL_NAME(f, r) (f->upvalues[r].name) 13 | 14 | #define LUADEC_TFORLOOP OP_TFORCALL 15 | #define FUNC_BLOCK_END(f) (f->sizecode) 16 | 17 | // Lua >= 5.2 : is_vararg = 0 1 , never use parament arg, but main has a global arg 18 | #define NEED_ARG(f) 0 19 | 20 | 21 | #define rawtsvalue(o) tsvalue(o) 22 | 23 | #ifdef tsslen 24 | #define LUA_STRLEN(ts) tsslen(ts) 25 | #else 26 | #define LUA_STRLEN(ts) ((ts)->len) 27 | #endif 28 | 29 | #define MAXREGS 250 30 | #define MAXSTACK MAXREGS 31 | 32 | #endif // #ifndef LUADEC_LUA_COMPAT_H 33 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_debug_file.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/glua/glua_debug_file.h -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_disassemble.h: -------------------------------------------------------------------------------- 1 | #ifndef glua_disassemble_h 2 | #define glua_disassemble_h 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace glua { 11 | namespace decompile { 12 | 13 | #define CC(r) (ISK((r)) ? 'K' : 'R') 14 | #define CV(r) (ISK((r)) ? INDEXK(r) : r) 15 | 16 | #define RK(r) (RegOrConst(f, r)) 17 | 18 | #define MAXCONSTSIZE 1024 19 | 20 | std::string luadec_disassemble(GluaDecompileContextP ctx, Proto* fwork, int dflag, std::string name); 21 | 22 | void luadec_disassembleSubFunction(GluaDecompileContextP ctx, Proto* f, int dflag, const char* funcnumstr); 23 | 24 | std::string RegOrConst(const Proto* f, int r); 25 | 26 | } 27 | } 28 | 29 | #endif // #ifndef glua_disassemble_h 30 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_loader.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef glua_loader_h 3 | #define glua_loader_h 4 | 5 | #include "glua/lprefix.h" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "glua/llimits.h" 12 | #include "glua/lstate.h" 13 | #include "glua/lua.h" 14 | #include "glua/thinkyoung_lua_api.h" 15 | 16 | namespace thinkyoung 17 | { 18 | namespace lua 19 | { 20 | namespace parser 21 | { 22 | 23 | class LuaLoader 24 | { 25 | private: 26 | GluaModuleByteStream *_stream; // byte code stream 27 | public: 28 | LuaLoader(GluaModuleByteStream *stream); 29 | ~LuaLoader(); 30 | 31 | void load_bytecode(); // load bytecode stream to AST 32 | }; 33 | 34 | } 35 | } 36 | } 37 | 38 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_parser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * if we need change lua syntax too mutch, reimplement the parser 3 | * @author 4 | */ 5 | 6 | #ifndef glua_parser_h 7 | #define glua_parser_h 8 | 9 | #include "glua/lprefix.h" 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "glua/lua.h" 17 | 18 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_tokenparser.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/glua/glua_tokenparser.h -------------------------------------------------------------------------------- /Chain/libraries/include/glua/glua_vm.h: -------------------------------------------------------------------------------- 1 | #ifndef glua_vm_h 2 | #define glua_vm_h 3 | 4 | #include 5 | #include 6 | 7 | namespace glua 8 | { 9 | namespace vm 10 | { 11 | 12 | class VMCallinfo 13 | { 14 | 15 | }; 16 | 17 | class VMState 18 | { 19 | 20 | }; 21 | 22 | typedef std::shared_ptr VMStateP; 23 | 24 | class VM 25 | { 26 | public: 27 | VM(); 28 | virtual ~VM(); 29 | 30 | // void load(); 31 | 32 | void execute(VMStateP state); 33 | }; 34 | } 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lcompile.h: -------------------------------------------------------------------------------- 1 | /** 2 | * lua module injector header in thinkyoung 3 | * @author 4 | */ 5 | 6 | #ifndef lcompile_h 7 | #define lcompile_h 8 | 9 | #include "glua/lprefix.h" 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "glua/lua.h" 17 | #include "glua/lobject.h" 18 | 19 | void luaL_PrintFunctionToFile(FILE *out, const Proto* f, int full); 20 | void luaL_PrintFunction(const Proto* f, int full); 21 | void luaL_PrintConstant(FILE *out, const Proto* f, int i); 22 | void luaL_PrintDebug(FILE *out, const Proto* f); 23 | void luaL_PrintHeader(FILE *out, const Proto* f); 24 | void luaL_PrintCode(FILE *out, const Proto* f); 25 | void luaL_PrintString(FILE *out, const TString* ts); 26 | 27 | #define luaU_print luaL_PrintFunction 28 | #define luaU_fprint luaL_PrintFunctionToFile 29 | 30 | #define PROGNAME "luac" /* default program name */ 31 | #define OUTPUT PROGNAME ".out" /* default output file */ 32 | 33 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "glua/lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (lua_cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC void luaG_typeerror(lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC void luaG_concaterror(lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC void luaG_opinterror(lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC void luaG_tointerror(lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC void luaG_ordererror(lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC void luaG_runerror(lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo(lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC void luaG_errormsg(lua_State *L, const char *msg=nullptr); 36 | LUAI_FUNC void luaG_traceexec(lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lobject.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/glua/lobject.h -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lrepl.h: -------------------------------------------------------------------------------- 1 | #ifndef lrepl_h 2 | #define lrepl_h 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "glua/lua.h" 9 | 10 | /* 11 | ** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and 12 | ** print any results. 13 | */ 14 | void luaL_doREPL(lua_State *L); 15 | 16 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lthinkyounglib.h: -------------------------------------------------------------------------------- 1 | #ifndef lthinkyounglib_h 2 | #define lthinkyounglib_h 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | namespace glua 22 | { 23 | namespace lib 24 | { 25 | int thinkyounglib_get_storage(lua_State *L); 26 | // thinkyoung.get_storage具体的实现 27 | int thinkyounglib_get_storage_impl(lua_State *L, 28 | const char *contract_id, const char *name); 29 | 30 | int thinkyounglib_set_storage(lua_State *L); 31 | 32 | int thinkyounglib_set_storage_impl(lua_State *L, 33 | const char *contract_id, const char *name, int value_index); 34 | } 35 | } 36 | 37 | #endif -------------------------------------------------------------------------------- /Chain/libraries/include/glua/ltype_checker_type_info.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/glua/ltype_checker_type_info.h -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "glua/lua.h" 7 | #include "glua/lualib.h" 8 | #include "glua/lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /Chain/libraries/include/glua/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "glua/llimits.h" 11 | #include "glua/lobject.h" 12 | #include "glua/lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump(lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump(lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Chain/libraries/include/net/ChainServerCommands.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * This is an internal header for alp. It does not contain any classes or functions intended for clients. 5 | * It exists purely as an implementation detail, and may change at any time without notice. 6 | */ 7 | 8 | #include 9 | 10 | const static uint32_t PROTOCOL_VERSION = 0; 11 | 12 | namespace thinkyoung { 13 | namespace net { 14 | namespace detail { 15 | enum ChainServerCommands { 16 | finish = 0, 17 | get_blocks_from_number 18 | }; 19 | } 20 | } 21 | } //namespace thinkyoung::net::detail 22 | 23 | FC_REFLECT_ENUM(thinkyoung::net::detail::ChainServerCommands, (finish)(get_blocks_from_number)) 24 | FC_REFLECT_TYPENAME(thinkyoung::net::detail::ChainServerCommands) 25 | -------------------------------------------------------------------------------- /Chain/libraries/include/net/Exceptions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace net { 6 | // registered in node.cpp 7 | 8 | FC_DECLARE_EXCEPTION(net_exception, 90000, "P2P Networking Exception"); 9 | FC_DECLARE_DERIVED_EXCEPTION(send_queue_overflow, thinkyoung::net::net_exception, 90001, "send queue for this peer exceeded maximum size"); 10 | FC_DECLARE_DERIVED_EXCEPTION(insufficient_relay_fee, thinkyoung::net::net_exception, 90002, "insufficient relay fee"); 11 | FC_DECLARE_DERIVED_EXCEPTION(already_connected_to_requested_peer, thinkyoung::net::net_exception, 90003, "already connected to requested peer"); 12 | FC_DECLARE_DERIVED_EXCEPTION(block_older_than_undo_history, thinkyoung::net::net_exception, 90004, "block is older than our undo history allows us to process"); 13 | FC_DECLARE_DERIVED_EXCEPTION(endpoint_in_blacklist, thinkyoung::net::net_exception, 90005, "node want to add is in the blacklist"); 14 | FC_DECLARE_DERIVED_EXCEPTION(no_active_endpoint, thinkyoung::net::net_exception, 90006, "disconnect endpoint is not in the active connection list"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Chain/libraries/include/net/Upnp.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace thinkyoung { 7 | namespace net { 8 | 9 | namespace detail { class UpnpServiceImpl; } 10 | 11 | class UpnpService 12 | { 13 | public: 14 | UpnpService(); 15 | ~UpnpService(); 16 | 17 | fc::ip::address external_ip()const; 18 | uint16_t mapped_port()const; 19 | void map_port(uint16_t p); 20 | private: 21 | std::unique_ptr my; 22 | }; 23 | 24 | } 25 | } // thinkyoung::net 26 | -------------------------------------------------------------------------------- /Chain/libraries/include/rpc/Exceptions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace thinkyoung { 6 | namespace rpc { 7 | 8 | // All registered in rpc_server.cpp 9 | FC_DECLARE_EXCEPTION(rpc_exception, 60000, "RPC Error"); 10 | FC_DECLARE_EXCEPTION(missing_parameter, 60001, "Missing Parameter"); 11 | FC_DECLARE_EXCEPTION(unknown_method, 60002, "Unknown Method"); 12 | FC_DECLARE_EXCEPTION(login_required, 60003, "Login Required"); 13 | 14 | } 15 | } // thinkyoung::rpc 16 | -------------------------------------------------------------------------------- /Chain/libraries/include/rpc/RpcClient.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace thinkyoung { 13 | namespace rpc { 14 | namespace detail { class RpcClientImpl; } 15 | 16 | /** 17 | * @class rpc_client 18 | * @brief provides a C++ interface to a remote ALP client over JSON-RPC 19 | */ 20 | class RpcClient : public thinkyoung::rpc_stubs::CommonApiRpcClient 21 | { 22 | public: 23 | RpcClient(); 24 | virtual ~RpcClient(); 25 | 26 | void connect_to(const fc::ip::endpoint& remote_endpoint, 27 | const blockchain::PublicKeyType& remote_public_key = blockchain::PublicKeyType()); 28 | 29 | bool login(const std::string& username, const std::string& password); 30 | virtual fc::rpc::json_connection_ptr get_json_connection() const override; 31 | void reset_json_connection(); 32 | private: 33 | std::unique_ptr my; 34 | }; 35 | typedef std::shared_ptr RpcClientPtr; 36 | } 37 | } // thinkyoung::rpc 38 | -------------------------------------------------------------------------------- /Chain/libraries/include/rpc/RpcClientApi.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace thinkyoung { 12 | namespace rpc { 13 | namespace detail { class RpcClientImpl; } 14 | 15 | using namespace thinkyoung::blockchain; 16 | using namespace thinkyoung::wallet; 17 | 18 | typedef vector > Balances; 19 | 20 | enum GenerateTransactionFlag 21 | { 22 | sign_and_broadcast = 0, 23 | do_not_broadcast = 1, 24 | do_not_sign = 2 25 | }; 26 | 27 | } 28 | } // thinkyoung::rpc 29 | FC_REFLECT_ENUM(thinkyoung::rpc::GenerateTransactionFlag, (do_not_broadcast)(do_not_sign)(sign_and_broadcast)) 30 | -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/CommonApi.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | namespace thinkyoung { 6 | namespace utilities { 7 | 8 | int common_fread_octets(FILE* fp, void* dst_stream, int len); 9 | int common_fread_int(FILE* fp, int* dst_int); 10 | 11 | int common_fwrite_stream(FILE* fp, const void* src_stream, int len); 12 | int common_fwrite_int(FILE* fp, const int* src_int); 13 | bool isNumber(std::string input); 14 | } 15 | } // end namespace thinkyoung::utilities -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/GitRevision.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace thinkyoung { 5 | namespace utilities { 6 | 7 | extern const char* const git_revision_sha; 8 | extern const uint32_t git_revision_unix_timestamp; 9 | extern const char* const git_revision_description; 10 | 11 | } 12 | } // end namespace thinkyoung::utilities 13 | -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/KeyConversion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace thinkyoung { 8 | namespace utilities { 9 | 10 | std::string key_to_wif_single_hash(const fc::ecc::private_key& key); 11 | std::string key_to_wif(const fc::ecc::private_key& key); 12 | fc::optional wif_to_key(const std::string& wif_key); 13 | 14 | } 15 | } // end namespace thinkyoung::utilities 16 | -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/PaddingOstream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace thinkyoung { 4 | namespace utilities { 5 | 6 | template 7 | class PaddingOstream : public fc::buffered_ostream { 8 | public: 9 | PaddingOstream(fc::ostream_ptr o, size_t bufsize = 4096) : buffered_ostream(o, bufsize) {} 10 | virtual ~PaddingOstream() {} 11 | 12 | virtual size_t writesome(const char* buffer, size_t len) { 13 | auto out = buffered_ostream::writesome(buffer, len); 14 | bytes_out += out; 15 | bytes_out %= BlockSize; 16 | return out; 17 | } 18 | virtual size_t writesome(const std::shared_ptr& buf, size_t len, size_t offset) { 19 | auto out = buffered_ostream::writesome(buf, len, offset); 20 | bytes_out += out; 21 | bytes_out %= BlockSize; 22 | return out; 23 | } 24 | virtual void flush() { 25 | static const char pad = PaddingChar; 26 | while (bytes_out % BlockSize) 27 | writesome(&pad, 1); 28 | buffered_ostream::flush(); 29 | } 30 | 31 | private: 32 | size_t bytes_out = 0; 33 | }; 34 | 35 | } 36 | } //thinkyoung::utilities 37 | 38 | -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/StringEscape.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace thinkyoung { 6 | namespace utilities { 7 | 8 | std::string escape_string_for_c_source_code(const std::string& input); 9 | 10 | } 11 | } // end namespace thinkyoung::utilities 12 | -------------------------------------------------------------------------------- /Chain/libraries/include/utilities/Words.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef const char* ConstCharRawPtr; 4 | extern const ConstCharRawPtr word_list[]; 5 | extern const uint32_t word_list_size; 6 | -------------------------------------------------------------------------------- /Chain/libraries/include/wallet/Config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define ALP_WALLET_VERSION uint32_t( 109 ) 4 | 5 | #define ALP_WALLET_MIN_PASSWORD_LENGTH 8 6 | #define ALP_WALLET_MIN_BRAINKEY_LENGTH 32 7 | 8 | #define ALP_WALLET_DEFAULT_UNLOCK_TIME_SEC ( 60 * 60 ) 9 | 10 | #define ALP_WALLET_DEFAULT_TRANSACTION_FEE 1000 // XTS 11 | 12 | #define ALP_WALLET_DEFAULT_TRANSACTION_EXPIRATION_SEC ( 60 * 60 ) 13 | 14 | #define WALLET_DEFAULT_MARKET_TRANSACTION_EXPIRATION_SEC ( 60 * 10 ) 15 | -------------------------------------------------------------------------------- /Chain/libraries/include/wallet/Url.hpp: -------------------------------------------------------------------------------- 1 | /* This is an autogenerated file, based on url.hpp.in 2 | Do not edit url.hpp directly! Edit url.hpp.in */ 3 | 4 | #pragma once 5 | 6 | #define CUSTOM_URL_SCHEME "thinkyoung" 7 | -------------------------------------------------------------------------------- /Chain/libraries/include/wallet/WalletEntrys.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/wallet/WalletEntrys.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/wallet/WalletImpl.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/include/wallet/WalletImpl.hpp -------------------------------------------------------------------------------- /Chain/libraries/include/wallet/url.hpp.in: -------------------------------------------------------------------------------- 1 | /* This is an autogenerated file, based on url.hpp.in 2 | Do not edit url.hpp directly! Edit url.hpp.in */ 3 | 4 | #pragma once 5 | 6 | #define CUSTOM_URL_SCHEME "@CUSTOM_URL_SCHEME@" 7 | -------------------------------------------------------------------------------- /Chain/libraries/rpc/RpcServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/rpc/RpcServer.cpp -------------------------------------------------------------------------------- /Chain/libraries/utilities/GitRevision.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define THINKYOUNG_GIT_REVISION_SHA "7e7f255f185ffaf53397084f6ca747674088f176" 5 | #define THINKYOUNG_GIT_REVISION_UNIX_TIMESTAMP 1488663957 6 | #define THINKYOUNG_GIT_REVISION_DESCRIPTION "3.1.3" 7 | 8 | namespace thinkyoung { 9 | namespace utilities { 10 | 11 | const char* const git_revision_sha = THINKYOUNG_GIT_REVISION_SHA; 12 | const uint32_t git_revision_unix_timestamp = THINKYOUNG_GIT_REVISION_UNIX_TIMESTAMP; 13 | const char* const git_revision_description = THINKYOUNG_GIT_REVISION_DESCRIPTION; 14 | 15 | } 16 | } // end namespace thinkyoung::utilities 17 | -------------------------------------------------------------------------------- /Chain/libraries/wallet/WalletDb.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/Chain/libraries/wallet/WalletDb.cpp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Achain Build instructions 2 | 3 | - Please read [linux_installation_guide](https://github.com/Achain-Dev/Achain_linux/blob/master/linux_installation_guide) and follow procedures in the document. 4 | 5 | - Besides, you could also just run **[ ./build_centos.sh download ](https://github.com/Achain-Dev/Achain_linux/blob/master/build_centos.sh)** or **[ ./build_ubuntu.sh download ](https://github.com/Achain-Dev/Achain_linux/blob/master/build_ubuntu.sh)** or **[ ./build_mac.sh download ](https://github.com/Achain-Dev/Achain_linux/blob/master/build_mac.sh)** to build Achain efficiently. 6 | 7 | 8 | # Supported Linux Platforms 9 | 10 | 11 | We already support the following platforms: 12 | 13 | * CentOS / RHEL / Oracle Linux 7.2.1511 / 7.3.1611 14 | * Ubuntu 16.04 15 | * MacOS Darwin 10.13 16 | * Fedora 27 / 25 17 | * Docker 18 | 19 | 20 | We will support the following platforms in the future: 21 | 22 | * Debian 23 | 24 | # Note 25 | 26 | After the release version of [Achain 2.0](https://github.com/Achain-Dev/Achain_linux/releases), the Linux repo would be deprecated. 27 | Please follow this [Achain repo](https://github.com/Achain-Dev/Achain). 28 | 29 | License 30 | ------ 31 | 32 | The Achain project is licensed under the [MIT license](LICENSE). 33 | -------------------------------------------------------------------------------- /include/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/include/.gitkeep -------------------------------------------------------------------------------- /include/fc/aligned.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace fc { 3 | 4 | template 5 | struct aligned { 6 | union { 7 | T _align; 8 | char _data[S]; 9 | } _store; 10 | operator char*() { return _store._data; } 11 | operator const char*()const { return _store._data; } 12 | }; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /include/fc/any.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | // TODO: define this without using boost 6 | typedef boost::any any; 7 | } 8 | -------------------------------------------------------------------------------- /include/fc/bitutil.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | 6 | inline uint64_t endian_reverse_u64( uint64_t x ) 7 | { 8 | return (((x >> 0x38) & 0xFF) ) 9 | | (((x >> 0x30) & 0xFF) << 0x08) 10 | | (((x >> 0x28) & 0xFF) << 0x10) 11 | | (((x >> 0x20) & 0xFF) << 0x18) 12 | | (((x >> 0x18) & 0xFF) << 0x20) 13 | | (((x >> 0x10) & 0xFF) << 0x28) 14 | | (((x >> 0x08) & 0xFF) << 0x30) 15 | | (((x ) & 0xFF) << 0x38) 16 | ; 17 | } 18 | 19 | inline uint32_t endian_reverse_u32( uint32_t x ) 20 | { 21 | return (((x >> 0x18) & 0xFF) ) 22 | | (((x >> 0x10) & 0xFF) << 0x08) 23 | | (((x >> 0x08) & 0xFF) << 0x10) 24 | | (((x ) & 0xFF) << 0x18) 25 | ; 26 | } 27 | 28 | } // namespace fc 29 | -------------------------------------------------------------------------------- /include/fc/compress/smaz.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | 6 | std::string smaz_compress( const std::string& in ); 7 | std::string smaz_decompress( const std::string& compressed ); 8 | 9 | } // namespace fc 10 | -------------------------------------------------------------------------------- /include/fc/compress/zlib.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace fc 6 | { 7 | 8 | string zlib_compress(const string& in); 9 | 10 | } // namespace fc 11 | -------------------------------------------------------------------------------- /include/fc/container/deque.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | namespace raw { 8 | 9 | 10 | } // namespace raw 11 | 12 | } // namespace fc 13 | -------------------------------------------------------------------------------- /include/fc/container/deque_fwd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace fc { 6 | 7 | namespace raw { 8 | template 9 | void pack( Stream& s, const std::deque& value ); 10 | template 11 | void unpack( Stream& s, std::deque& value ); 12 | } 13 | } // namespace fc 14 | -------------------------------------------------------------------------------- /include/fc/container/flat_fwd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | 7 | using boost::container::flat_map; 8 | using boost::container::flat_set; 9 | 10 | namespace raw { 11 | template 12 | void pack( Stream& s, const flat_set& value ); 13 | template 14 | void unpack( Stream& s, flat_set& value ); 15 | template 16 | void pack( Stream& s, const flat_map& value ); 17 | template 18 | void unpack( Stream& s, flat_map& value ) ; 19 | } // namespace raw 20 | 21 | } // fc 22 | -------------------------------------------------------------------------------- /include/fc/crypto/base32.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc 6 | { 7 | std::vector from_base32( const fc::string& b32 ); 8 | fc::string to_base32( const std::vector& vec ); 9 | fc::string to_base32( const char* data, size_t len ); 10 | } 11 | -------------------------------------------------------------------------------- /include/fc/crypto/base36.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc 6 | { 7 | std::vector from_base36( const fc::string& b36 ); 8 | fc::string to_base36( const std::vector& vec ); 9 | fc::string to_base36( const char* data, size_t len ); 10 | } 11 | -------------------------------------------------------------------------------- /include/fc/crypto/base58.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | std::string to_base58( const char* d, size_t s ); 7 | std::string to_base58( const std::vector& data ); 8 | std::vector from_base58( const std::string& base58_str ); 9 | size_t from_base58( const std::string& base58_str, char* out_data, size_t out_data_len ); 10 | } 11 | -------------------------------------------------------------------------------- /include/fc/crypto/base64.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len); 6 | inline std::string base64_encode(char const* bytes_to_encode, unsigned int in_len) { return base64_encode( (unsigned char const*)bytes_to_encode, in_len); } 7 | std::string base64_encode( const std::string& enc ); 8 | std::string base64_decode( const std::string& encoded_string); 9 | } // namespace fc 10 | -------------------------------------------------------------------------------- /include/fc/crypto/dh.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | 8 | struct diffie_hellman { 9 | diffie_hellman():valid(0),g(5){ fc::init_openssl(); } 10 | bool generate_params( int s, uint8_t g ); 11 | bool generate_pub_key(); 12 | bool compute_shared_key( const char* buf, uint32_t s ); 13 | bool compute_shared_key( const std::vector& pubk); 14 | bool validate(); 15 | 16 | std::vector p; 17 | std::vector pub_key; 18 | std::vector priv_key; 19 | std::vector shared_key; 20 | bool valid; 21 | uint8_t g; 22 | }; 23 | 24 | } // namespace fc 25 | 26 | 27 | -------------------------------------------------------------------------------- /include/fc/crypto/digest.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | 8 | template 9 | fc::sha256 digest( const T& value ) 10 | { 11 | fc::sha256::encoder enc; 12 | fc::raw::pack( enc, value ); 13 | return enc.result(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /include/fc/crypto/hex.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | uint8_t from_hex( char c ); 8 | fc::string to_hex( const char* d, uint32_t s ); 9 | std::string to_hex( const std::vector& data ); 10 | 11 | /** 12 | * @return the number of bytes decoded 13 | */ 14 | size_t from_hex( const fc::string& hex_str, char* out_data, size_t out_data_len ); 15 | } 16 | -------------------------------------------------------------------------------- /include/fc/crypto/rand.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | 5 | /* provides access to the OpenSSL random number generator */ 6 | void rand_bytes(char* buf, int count); 7 | void rand_pseudo_bytes(char* buf, int count); 8 | } // namespace fc 9 | -------------------------------------------------------------------------------- /include/fc/fwd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | 6 | /** 7 | * @brief Used to forward declare value types. 8 | * 9 | */ 10 | template 11 | class fwd { 12 | public: 13 | template fwd( U&& u ); 14 | template fwd( U&& u, V&& v ); 15 | template fwd( U&& u, V&& v, X&&, Y&& ); 16 | fwd(); 17 | 18 | fwd( const fwd& f ); 19 | fwd( fwd&& f ); 20 | 21 | operator const T&()const; 22 | operator T&(); 23 | 24 | T& operator*(); 25 | const T& operator*()const; 26 | const T* operator->()const; 27 | 28 | T* operator->(); 29 | bool operator !()const; 30 | 31 | template 32 | T& operator = ( U&& u ); 33 | 34 | T& operator = ( fwd&& u ); 35 | T& operator = ( const fwd& u ); 36 | 37 | ~fwd(); 38 | 39 | private: 40 | aligned _store; 41 | }; 42 | 43 | 44 | } // namespace fc 45 | 46 | -------------------------------------------------------------------------------- /include/fc/git_revision.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | 6 | extern const char* const git_revision_sha; 7 | extern const uint32_t git_revision_unix_timestamp; 8 | 9 | } // end namespace fc 10 | -------------------------------------------------------------------------------- /include/fc/interprocess/file_mapping.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace boost { 6 | namespace interprocess { 7 | class file_mapping; 8 | class mapped_region; 9 | } 10 | } 11 | namespace fc { 12 | enum mode_t { 13 | read_only, 14 | write_only, 15 | read_write 16 | }; 17 | 18 | class file_mapping { 19 | public: 20 | file_mapping( const char* file, mode_t ); 21 | ~file_mapping(); 22 | private: 23 | friend class mapped_region; 24 | #ifdef _WIN64 25 | fc::fwd my; 26 | #else 27 | fc::fwd my; 28 | #endif 29 | }; 30 | 31 | class mapped_region { 32 | public: 33 | mapped_region( const file_mapping& fm, mode_t m, uint64_t start, size_t size ); 34 | mapped_region( const file_mapping& fm, mode_t m ); 35 | ~mapped_region(); 36 | void flush(); 37 | void* get_address()const; 38 | size_t get_size()const; 39 | private: 40 | fc::fwd my; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /include/fc/interprocess/process.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | 6 | fc::path find_executable_in_path( const fc::string name ); 7 | 8 | /** 9 | * @brief start and manage an local process 10 | * @note this class implements reference semantics. 11 | */ 12 | class process : public iprocess 13 | { 14 | public: 15 | process(); 16 | ~process(); 17 | 18 | virtual iprocess& exec( const fc::path& exe, 19 | std::vector args, 20 | const fc::path& work_dir = fc::path(), 21 | int opts = open_all ); 22 | 23 | 24 | virtual int result(const microseconds& timeout = microseconds::maximum()); 25 | virtual void kill(); 26 | virtual fc::buffered_ostream_ptr in_stream(); 27 | virtual fc::buffered_istream_ptr out_stream(); 28 | virtual fc::buffered_istream_ptr err_stream(); 29 | 30 | class impl; 31 | private: 32 | std::unique_ptr my; 33 | }; 34 | 35 | typedef std::shared_ptr process_ptr; 36 | 37 | } // namespace fc 38 | -------------------------------------------------------------------------------- /include/fc/interprocess/signals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc 5 | { 6 | /// handler will be called from ASIO thread 7 | void set_signal_handler( std::function handler, int signal_num ); 8 | } 9 | -------------------------------------------------------------------------------- /include/fc/io/console.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | namespace fc 3 | { 4 | /** enables / disables echoing of console input, useful for 5 | * entering passwords on the console. 6 | */ 7 | void set_console_echo( bool enable_echo ); 8 | } // namespace fc 9 | -------------------------------------------------------------------------------- /include/fc/io/raw_unpack_file.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace fc 8 | { 9 | namespace raw 10 | { 11 | template 12 | void unpack_file( const fc::path& filename, T& obj ) 13 | { 14 | try { 15 | fc::file_mapping fmap( filename.generic_string().c_str(), fc::read_only); 16 | fc::mapped_region mapr( fmap, fc::read_only, 0, fc::file_size(filename) ); 17 | auto cs = (const char*)mapr.get_address(); 18 | 19 | fc::datastream ds( cs, mapr.get_size() ); 20 | fc::raw::unpack(ds,obj); 21 | } FC_RETHROW_EXCEPTIONS( info, "unpacking file ${file}", ("file",filename) ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /include/fc/io/sstream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | 7 | class stringstream : virtual public iostream { 8 | public: 9 | stringstream(); 10 | stringstream( fc::string& s); 11 | stringstream( const fc::string& s); 12 | ~stringstream(); 13 | 14 | fc::string str(); 15 | void str(const fc::string& s); 16 | 17 | void clear(); 18 | 19 | virtual bool eof()const; 20 | virtual size_t writesome( const char* buf, size_t len ); 21 | virtual size_t writesome( const std::shared_ptr& buf, size_t len, size_t offset ); 22 | virtual size_t readsome( char* buf, size_t len ); 23 | virtual size_t readsome( const std::shared_ptr& buf, size_t len, size_t offset ); 24 | virtual void close(); 25 | virtual void flush(); 26 | char peek(); 27 | 28 | private: 29 | class impl; 30 | fwd my; 31 | }; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /include/fc/io/stdio.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc 5 | { 6 | 7 | class cout_t : virtual public ostream { 8 | public: 9 | virtual size_t writesome( const char* buf, size_t len ); 10 | virtual size_t writesome( const std::shared_ptr& buf, size_t len, size_t offset ); 11 | virtual void close(); 12 | virtual void flush(); 13 | }; 14 | 15 | class cerr_t : virtual public ostream { 16 | public: 17 | virtual size_t writesome( const char* buf, size_t len ); 18 | virtual size_t writesome( const std::shared_ptr& buf, size_t len, size_t offset ); 19 | virtual void close(); 20 | virtual void flush(); 21 | }; 22 | 23 | class cin_t : virtual public istream { 24 | public: 25 | ~cin_t(); 26 | virtual size_t readsome( char* buf, size_t len ); 27 | virtual size_t readsome( const std::shared_ptr& buf, size_t len, size_t offset ); 28 | virtual istream& read( char* buf, size_t len ); 29 | virtual bool eof()const; 30 | }; 31 | 32 | extern cout_t& cout; 33 | extern cerr_t& cerr; 34 | extern cin_t& cin; 35 | 36 | extern std::shared_ptr cin_ptr; 37 | extern std::shared_ptr cout_ptr; 38 | extern std::shared_ptr cerr_ptr; 39 | } 40 | -------------------------------------------------------------------------------- /include/fc/log/appender.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | class appender; 7 | class log_message; 8 | class variant; 9 | 10 | class appender_factory : public fc::retainable { 11 | public: 12 | typedef fc::shared_ptr ptr; 13 | 14 | virtual ~appender_factory(){}; 15 | virtual fc::shared_ptr create( const variant& args ) = 0; 16 | }; 17 | 18 | namespace detail { 19 | template 20 | class appender_factory_impl : public appender_factory { 21 | public: 22 | virtual fc::shared_ptr create( const variant& args ) { 23 | return fc::shared_ptr(new T(args)); 24 | } 25 | }; 26 | } 27 | 28 | class appender : public fc::retainable { 29 | public: 30 | typedef fc::shared_ptr ptr; 31 | 32 | template 33 | static bool register_appender(const fc::string& type) { 34 | return register_appender( type, new detail::appender_factory_impl() ); 35 | } 36 | 37 | static appender::ptr create( const fc::string& name, const fc::string& type, const variant& args ); 38 | static appender::ptr get( const fc::string& name ); 39 | static bool register_appender( const fc::string& type, const appender_factory::ptr& f ); 40 | 41 | virtual void log( const log_message& m ) = 0; 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /include/fc/log/file_appender.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace fc { 9 | 10 | class file_appender : public appender { 11 | public: 12 | struct config { 13 | config( const fc::path& p = "log.txt" ); 14 | 15 | fc::string format; 16 | fc::path filename; 17 | bool flush = true; 18 | bool rotate = false; 19 | microseconds rotation_interval; 20 | microseconds rotation_limit; 21 | }; 22 | file_appender( const variant& args ); 23 | ~file_appender(); 24 | virtual void log( const log_message& m )override; 25 | 26 | private: 27 | class impl; 28 | fc::shared_ptr my; 29 | }; 30 | } // namespace fc 31 | 32 | #include 33 | FC_REFLECT( fc::file_appender::config, 34 | (format)(filename)(flush)(rotate)(rotation_interval)(rotation_limit) ) 35 | -------------------------------------------------------------------------------- /include/fc/log/gelf_appender.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace fc 8 | { 9 | // Log appender that sends log messages in JSON format over UDP 10 | // https://www.graylog2.org/resources/gelf/specification 11 | class gelf_appender : public appender 12 | { 13 | public: 14 | struct config 15 | { 16 | string endpoint = "127.0.0.1:12201"; 17 | string host = "fc"; // the name of the host, source or application that sent this message (just passed through to GELF server) 18 | }; 19 | 20 | gelf_appender(const variant& args); 21 | ~gelf_appender(); 22 | virtual void log(const log_message& m) override; 23 | 24 | private: 25 | class impl; 26 | fc::shared_ptr my; 27 | }; 28 | } // namespace fc 29 | 30 | #include 31 | FC_REFLECT(fc::gelf_appender::config, 32 | (endpoint)(host)) 33 | -------------------------------------------------------------------------------- /include/fc/make_fused.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | template 7 | std::function > make_fused( const std::function& f ) { 8 | return [=]( fc::tuple<> ){ return f(); }; 9 | } 10 | template 11 | std::function) > make_fused( const std::function& f ) { 12 | return [f]( fc::tuple t){ return f(t.a); }; 13 | } 14 | template 15 | std::function) > make_fused( const std::function& f ) { 16 | return [f]( fc::tuple t){ return f(t.a,t.b); }; 17 | } 18 | template 19 | std::function) > make_fused( const std::function& f ) { 20 | return [f]( fc::tuple t){ return f(t.a,t.b,t.c); }; 21 | } 22 | template 23 | std::function) > make_fused( const std::function& f ) { 24 | return [f]( fc::tuple t){ return f(t.a,t.b,t.c,t.d); }; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /include/fc/network/ntp.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | namespace fc { 9 | 10 | namespace detail { class ntp_impl; } 11 | 12 | class ntp 13 | { 14 | public: 15 | ntp(); 16 | ~ntp(); 17 | 18 | void add_server( const std::string& hostname, uint16_t port = 123 ); 19 | void set_request_interval( uint32_t interval_sec ); 20 | void request_now(); 21 | optional get_time()const; 22 | 23 | private: 24 | std::unique_ptr my; 25 | }; 26 | 27 | } // namespace fc 28 | -------------------------------------------------------------------------------- /include/fc/network/rate_limiting.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace fc 9 | { 10 | namespace detail 11 | { 12 | class rate_limiting_group_impl; 13 | } 14 | 15 | class tcp_socket; 16 | 17 | class rate_limiting_group 18 | { 19 | public: 20 | rate_limiting_group(uint32_t upload_bytes_per_second, uint32_t download_bytes_per_second, uint32_t burstiness_in_seconds = 1); 21 | ~rate_limiting_group(); 22 | 23 | void set_upload_limit(uint32_t upload_bytes_per_second); 24 | uint32_t get_upload_limit() const; 25 | 26 | void set_download_limit(uint32_t download_bytes_per_second); 27 | uint32_t get_download_limit() const; 28 | 29 | uint32_t get_actual_upload_rate() const; 30 | uint32_t get_actual_download_rate() const; 31 | void set_actual_rate_time_constant(microseconds time_constant); 32 | 33 | void add_tcp_socket(tcp_socket* tcp_socket_to_limit); 34 | void remove_tcp_socket(tcp_socket* tcp_socket_to_stop_limiting); 35 | private: 36 | std::unique_ptr my; 37 | }; 38 | typedef std::shared_ptr rate_limiting_group_ptr; 39 | 40 | } // namesapce fc 41 | 42 | -------------------------------------------------------------------------------- /include/fc/network/resolve.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc 6 | { 7 | std::vector resolve( const std::string& host, uint16_t port ); 8 | } 9 | -------------------------------------------------------------------------------- /include/fc/network/tcp_socket_io_hooks.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace fc 5 | { 6 | class tcp_socket_io_hooks 7 | { 8 | public: 9 | virtual ~tcp_socket_io_hooks() {} 10 | virtual size_t readsome(boost::asio::ip::tcp::socket& socket, char* buffer, size_t length) = 0; 11 | virtual size_t readsome(boost::asio::ip::tcp::socket& socket, const std::shared_ptr& buffer, size_t length, size_t offset) = 0; 12 | virtual size_t writesome(boost::asio::ip::tcp::socket& socket, const char* buffer, size_t length) = 0; 13 | virtual size_t writesome(boost::asio::ip::tcp::socket& socket, const std::shared_ptr& buffer, size_t length, size_t offset) = 0; 14 | }; 15 | } // namesapce fc 16 | -------------------------------------------------------------------------------- /include/fc/network/udp_socket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | namespace fc { 7 | namespace ip { 8 | class endpoint; 9 | class address; 10 | } 11 | 12 | /** 13 | * The udp_socket class has reference semantics, all copies will 14 | * refer to the same underlying socket. 15 | */ 16 | class udp_socket { 17 | public: 18 | udp_socket(); 19 | udp_socket( const udp_socket& s ); 20 | ~udp_socket(); 21 | 22 | void open(); 23 | void set_receive_buffer_size( size_t s ); 24 | void bind( const fc::ip::endpoint& ); 25 | size_t receive_from( char* b, size_t l, fc::ip::endpoint& from ); 26 | size_t receive_from( const std::shared_ptr& b, size_t l, fc::ip::endpoint& from ); 27 | size_t send_to( const char* b, size_t l, const fc::ip::endpoint& to ); 28 | size_t send_to( const std::shared_ptr& b, size_t l, const fc::ip::endpoint& to ); 29 | void close(); 30 | 31 | void set_multicast_enable_loopback( bool ); 32 | void set_reuse_address( bool ); 33 | void join_multicast_group( const fc::ip::address& a ); 34 | 35 | void connect( const fc::ip::endpoint& e ); 36 | fc::ip::endpoint local_endpoint()const; 37 | 38 | private: 39 | class impl; 40 | fc::shared_ptr my; 41 | }; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /include/fc/noncopyable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc 4 | { 5 | class noncopyable 6 | { 7 | public: 8 | noncopyable(){} 9 | private: 10 | noncopyable( const noncopyable& ) = delete; 11 | noncopyable& operator=( const noncopyable& ) = delete; 12 | }; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /include/fc/platform_independence.hpp: -------------------------------------------------------------------------------- 1 | #ifdef _MSC_VER 2 | #include 3 | #ifdef _M_X64 4 | #define __builtin_popcountll __popcnt64 5 | #else 6 | inline int __builtin_popcountll(unsigned __int64 value) 7 | { 8 | unsigned int lowBits = (unsigned int)value; 9 | int count = __popcnt(lowBits); 10 | unsigned int highBits = (unsigned int)(value >> 32); 11 | count += __popcnt(highBits); 12 | return count; 13 | } 14 | #endif 15 | #endif -------------------------------------------------------------------------------- /include/fc/rpc/cli.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace fc { namespace rpc { 12 | 13 | /** 14 | * Provides a simple wrapper for RPC calls to a given interface. 15 | */ 16 | class cli : public api_connection 17 | { 18 | public: 19 | ~cli(); 20 | 21 | virtual variant send_call( api_id_type api_id, string method_name, variants args = variants() ); 22 | virtual variant send_callback( uint64_t callback_id, variants args = variants() ); 23 | virtual void send_notice( uint64_t callback_id, variants args = variants() ); 24 | 25 | void start(); 26 | void stop(); 27 | void wait(); 28 | void format_result( const string& method, std::function formatter); 29 | 30 | virtual void getline( const fc::string& prompt, fc::string& line ); 31 | 32 | void set_prompt( const string& prompt ); 33 | 34 | private: 35 | void run(); 36 | 37 | std::string _prompt = ">>>"; 38 | std::map > _result_formatters; 39 | fc::future _run_complete; 40 | }; 41 | } } 42 | -------------------------------------------------------------------------------- /include/fc/rpc/http_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace fc { namespace rpc { 10 | 11 | class http_api_connection : public api_connection 12 | { 13 | public: 14 | http_api_connection(); 15 | ~http_api_connection(); 16 | 17 | virtual variant send_call( 18 | api_id_type api_id, 19 | string method_name, 20 | variants args = variants() ) override; 21 | virtual variant send_callback( 22 | uint64_t callback_id, 23 | variants args = variants() ) override; 24 | virtual void send_notice( 25 | uint64_t callback_id, 26 | variants args = variants() ) override; 27 | 28 | void on_request( 29 | const fc::http::request& req, 30 | const fc::http::server::response& resp ); 31 | 32 | fc::rpc::state _rpc_state; 33 | }; 34 | 35 | } } // namespace fc::rpc 36 | -------------------------------------------------------------------------------- /include/fc/rpc/variant_stream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc 4 | { 5 | 6 | /** 7 | * Thread-safe, circular buffer for passing variants 8 | * between threads. 9 | */ 10 | class variant_stream 11 | { 12 | public: 13 | variant_stream( size_t s ); 14 | ~variant_stream(); 15 | 16 | /** producer api */ 17 | int64_t free(); // number of spaces available 18 | int64_t claim( int64_t num ); 19 | int64_t publish( int64_t pos ); 20 | int64_t wait_free(); // wait for free space 21 | 22 | // producer/consumer api 23 | variant& get( int64_t pos ); 24 | 25 | /** consumer api */ 26 | int64_t begin(); // returns the first index ready to be read 27 | int64_t end(); // returns the first index that cannot be read 28 | int64_t wait(); // wait for variants to be posted 29 | 30 | private: 31 | std::vector _variants; 32 | uint64_t _read_pos; 33 | uint64_t _write_pos; 34 | }; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /include/fc/rpc/websocket_api.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace fc { namespace rpc { 9 | 10 | class websocket_api_connection : public api_connection 11 | { 12 | public: 13 | websocket_api_connection( fc::http::websocket_connection& c ); 14 | ~websocket_api_connection(); 15 | 16 | virtual variant send_call( 17 | api_id_type api_id, 18 | string method_name, 19 | variants args = variants() ) override; 20 | virtual variant send_callback( 21 | uint64_t callback_id, 22 | variants args = variants() ) override; 23 | virtual void send_notice( 24 | uint64_t callback_id, 25 | variants args = variants() ) override; 26 | 27 | protected: 28 | std::string on_message( 29 | const std::string& message, 30 | bool send_message = true ); 31 | 32 | fc::http::websocket_connection& _connection; 33 | fc::rpc::state _rpc_state; 34 | }; 35 | 36 | } } // namespace fc::rpc 37 | -------------------------------------------------------------------------------- /include/fc/smart_ref_fwd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | /** 5 | * @brief Used to forward declare value types and break circular dependencies or use heap allocation 6 | * 7 | * A smart reference is heap allocated, move-aware, and is gauranteed to never be null (except after a move) 8 | */ 9 | template 10 | class smart_ref { 11 | public: 12 | template smart_ref( U&& u ); 13 | template smart_ref( U&& u, V&& v ); 14 | template smart_ref( U&& u, V&& v, X&&, Y&& ); 15 | smart_ref(); 16 | 17 | smart_ref( const smart_ref& f ); 18 | smart_ref( smart_ref&& f ); 19 | 20 | operator const T&()const; 21 | operator T&(); 22 | 23 | T& operator*(); 24 | const T& operator*()const; 25 | const T* operator->()const; 26 | 27 | T* operator->(); 28 | bool operator !()const; 29 | 30 | template 31 | T& operator = ( U&& u ); 32 | 33 | T& operator = ( smart_ref&& u ); 34 | T& operator = ( const smart_ref& u ); 35 | 36 | ~smart_ref(); 37 | 38 | private: 39 | T* impl; 40 | }; 41 | } 42 | -------------------------------------------------------------------------------- /include/fc/ssh/error.hpp: -------------------------------------------------------------------------------- 1 | #ifndef MACE_SSH_ERROR_HPP 2 | #define MACE_SSH_ERROR_HPP 3 | #include 4 | #include 5 | 6 | namespace mace { namespace ssh { 7 | typedef boost::error_info err_msg; 8 | 9 | struct exception : public virtual boost::exception, public virtual std::exception { 10 | const char* what()const throw() { return "exception"; } 11 | virtual void rethrow()const { BOOST_THROW_EXCEPTION(*this); } 12 | const std::string& message()const { return *boost::get_error_info(*this); } 13 | }; 14 | 15 | } } // mace::ssh 16 | 17 | /** 18 | * Helper macro for throwing exceptions with a message: THROW( "Hello World %1%, %2%", %"Hello" %"World" ) 19 | */ 20 | #define MACE_SSH_THROW( MSG, ... ) \ 21 | do { \ 22 | BOOST_THROW_EXCEPTION( mace::ssh::exception() << mace::ssh::err_msg( (boost::format( MSG ) __VA_ARGS__ ).str() ) );\ 23 | } while(0) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/fc/thread/non_preemptable_scope_check.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | // This file defines a macro: 6 | // ASSERT_TASK_NOT_PREEMPTED() 7 | // This macro is used to declare that the current scope is not expected to yield. 8 | // If the task does yield, it will generate an assertion. 9 | // 10 | // Use this when you you're coding somethign that must not yield, and you think you 11 | // have done it (just by virtue of the fact that you don't think you've called any 12 | // functions that could yield). This will help detect when your assumptions are 13 | // wrong and you accidentally call something that yields. 14 | // 15 | // This has no cost in release mode, and is extremely cheap in debug mode. 16 | 17 | #define FC_NON_PREEMPTABLE_SCOPE_COMBINE_HELPER(x,y) x ## y 18 | #define FC_NON_PREEMPTABLE_SCOPE_COMBINE(x,y) FC_NON_PREEMPTABLE_SCOPE_COMBINE_HELPER(x,y) 19 | 20 | #ifdef NDEBUG 21 | # define ASSERT_TASK_NOT_PREEMPTED() do {} while (0) 22 | #else 23 | # define ASSERT_TASK_NOT_PREEMPTED() fc::non_preemptable_scope_check FC_NON_PREEMPTABLE_SCOPE_COMBINE(scope_checker_, __LINE__) 24 | 25 | namespace fc 26 | { 27 | class non_preemptable_scope_check 28 | { 29 | public: 30 | non_preemptable_scope_check(); 31 | ~non_preemptable_scope_check(); 32 | }; 33 | } // namespace fc 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /include/fc/thread/priority.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _FC_PRIORITY_HPP_ 2 | #define _FC_PRIORITY_HPP_ 3 | 4 | namespace fc { 5 | /** 6 | * An integer value used to sort asynchronous tasks. The higher the 7 | * prioirty the sooner it will be run. 8 | */ 9 | class priority { 10 | public: 11 | explicit priority( int v = 0):value(v){} 12 | priority( const priority& p ):value(p.value){} 13 | bool operator < ( const priority& p )const { 14 | return value < p.value; 15 | } 16 | static priority max() { return priority(10000); } 17 | static priority min() { return priority(-10000); } 18 | static priority _internal__priority_for_short_sleeps() { return priority(-100000); } 19 | int value; 20 | }; 21 | } 22 | #endif // _FC_PRIORITY_HPP_ 23 | -------------------------------------------------------------------------------- /include/fc/thread/scoped_lock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | template 5 | class scoped_lock { 6 | public: 7 | scoped_lock( T& l ):_lock(l) { _lock.lock(); } 8 | ~scoped_lock() { _lock.unlock(); } 9 | T& _lock; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /include/fc/thread/spin_lock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | class microseconds; 5 | class time_point; 6 | 7 | /** 8 | * @class spin_lock 9 | * @brief modified spin-lock that yields on failure, but becomes a 'spin lock' 10 | * if there are no other tasks to yield to. 11 | * 12 | * This kind of lock is lighter weight than a full mutex, but potentially slower 13 | * than a staight spin_lock. 14 | * 15 | * This spin_lock does not block the current thread, but instead attempts to use 16 | * an atomic operation to aquire the lock. If unsuccessful, then it yields to 17 | * other tasks before trying again. If there are no other tasks then yield is 18 | * a no-op and spin_lock becomes a spin-lock. 19 | */ 20 | class spin_lock { 21 | public: 22 | spin_lock(); 23 | bool try_lock(); 24 | bool try_lock_for( const microseconds& rel_time ); 25 | bool try_lock_until( const time_point& abs_time ); 26 | void lock(); 27 | void unlock(); 28 | 29 | private: 30 | enum lock_store {locked,unlocked}; 31 | int _lock; 32 | }; 33 | 34 | } // namespace fc 35 | 36 | -------------------------------------------------------------------------------- /include/fc/thread/spin_yield_lock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace fc { 4 | class microseconds; 5 | class time_point; 6 | 7 | /** 8 | * @class spin_yield_lock 9 | * @brief modified spin-lock that yields on failure, but becomes a 'spin lock' 10 | * if there are no other tasks to yield to. 11 | * 12 | * This kind of lock is lighter weight than a full mutex, but potentially slower 13 | * than a staight spin_lock. 14 | * 15 | * This spin_yield_lock does not block the current thread, but instead attempts to use 16 | * an atomic operation to aquire the lock. If unsuccessful, then it yields to 17 | * other tasks before trying again. If there are no other tasks then yield is 18 | * a no-op and spin_yield_lock becomes a spin-lock. 19 | */ 20 | class spin_yield_lock { 21 | public: 22 | spin_yield_lock(); 23 | bool try_lock(); 24 | bool try_lock_for( const microseconds& rel_time ); 25 | bool try_lock_until( const time_point& abs_time ); 26 | void lock(); 27 | void unlock(); 28 | 29 | private: 30 | enum lock_store {locked,unlocked}; 31 | int _lock; 32 | }; 33 | 34 | } // namespace fc 35 | 36 | -------------------------------------------------------------------------------- /include/fc/thread/unique_lock.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace fc { 5 | struct try_to_lock_t{}; 6 | class time_point; 7 | 8 | /** 9 | * Including Boost's unique lock drastically increases compile times 10 | * for something that is this trivial! 11 | */ 12 | template 13 | class unique_lock { 14 | public: 15 | unique_lock( T& l, const fc::time_point& abs ):_lock(l) { _locked = _lock.try_lock_until(abs); } 16 | unique_lock( T& l, try_to_lock_t ):_lock(l) { _locked = _lock.try_lock(); } 17 | unique_lock( T& l ): _locked(false), _lock(l) { lock(); } 18 | ~unique_lock() { if (_locked) unlock(); } 19 | operator bool() const { return _locked; } 20 | void unlock() { assert(_locked); if (_locked) { _lock.unlock(); _locked = false;} } 21 | void lock() { assert(!_locked); if (!_locked) { _lock.lock(); _locked = true; } } 22 | private: 23 | unique_lock( const unique_lock& ); 24 | unique_lock& operator=( const unique_lock& ); 25 | bool _locked; 26 | T& _lock; 27 | }; 28 | 29 | } 30 | 31 | /** 32 | * Emulate java with the one quirk that the open bracket must come before 33 | * the synchronized 'keyword'. 34 | * 35 | * 36 | { synchronized( lock_type ) 37 | 38 | } 39 | * 40 | */ 41 | #define synchronized(X) fc::unique_lock __lock(((X))); 42 | 43 | -------------------------------------------------------------------------------- /include/fc/unique_ptr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc 6 | { 7 | template 8 | class unique_ptr 9 | { 10 | public: 11 | typedef T* pointer; 12 | 13 | explicit unique_ptr( pointer t = nullptr ):_p(t){} 14 | 15 | unique_ptr( unique_ptr&& m ) 16 | :_p(m._p){ m._p = nullptr; } 17 | 18 | ~unique_ptr() { delete _p; } 19 | 20 | operator bool()const { return _p != nullptr; } 21 | friend bool operator==(const unique_ptr& p, nullptr_t) 22 | { 23 | return p._p == nullptr; 24 | } 25 | 26 | friend bool operator!=(const unique_ptr& p, nullptr_t) 27 | { 28 | return p._p != nullptr; 29 | } 30 | 31 | unique_ptr& operator=( nullptr_t ) 32 | { 33 | delete _p; _p = nullptr; 34 | } 35 | 36 | unique_ptr& operator=( unique_ptr&& o ) 37 | { 38 | fc_swap( _p, o._p ); 39 | return *this; 40 | } 41 | 42 | pointer operator->()const { return _p; } 43 | T& operator*()const { return *_p; } 44 | 45 | void reset( pointer v ) 46 | { 47 | delete _p; _p = v; 48 | } 49 | pointer release() 50 | { 51 | auto tmp = _p; 52 | _p = nullptr; 53 | return tmp; 54 | } 55 | 56 | private: 57 | pointer _p; 58 | }; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /include/fc/utf8.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __UTF8_HPP 2 | #define __UTF8_HPP 3 | 4 | #include 5 | 6 | /// This file contains general purpose utilities related to UTF-8 <-> Unicode conversions 7 | 8 | namespace fc 9 | { 10 | 11 | bool is_utf8( const std::string& str ); 12 | 13 | /** Decodes utf 8 std::string into unicode string. 14 | @param input - input string to be decoded and stored in 'storage' 15 | @param storage - buffer for converted text. Cannot be nullptr. 16 | */ 17 | void decodeUtf8(const std::string& input, std::wstring* storage); 18 | 19 | /** Encodes given wide (unicode) string into UTF-8 representation. 20 | @param input - input string to be encoded and stored in 'storage' 21 | @param storage - buffer for converted text. Cannot be nullptr. 22 | */ 23 | void encodeUtf8(const std::wstring& input, std::string* storage); 24 | 25 | } /// namespace fc 26 | 27 | #endif ///__UTF8_HPP 28 | 29 | -------------------------------------------------------------------------------- /include/fc/vector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | -------------------------------------------------------------------------------- /include/fc/vector_fwd.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _FC_VECTOR_FWD_HPP_ 2 | #define _FC_VECTOR_FWD_HPP_ 3 | #if 0 4 | #include 5 | #else 6 | namespace fc { 7 | template class vector; 8 | }; 9 | #endif 10 | 11 | #endif // _FC_VECTOR_FWD_HPP_ 12 | -------------------------------------------------------------------------------- /include/fc/wait_any.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace fc { 6 | template 7 | int wait_any( fc::future& f1, fc::future& f2, const microseconds& timeout_us = microseconds::max() ) { 8 | fc::vector p(2); 9 | p[0] = static_pointer_cast(f1.promise()); 10 | p[1] = static_pointer_cast(f2.promise()); 11 | return wait( fc::move(p), timeout_us ); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /include/leveldb/dumpfile.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014 The LevelDB Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. See the AUTHORS file for names of contributors. 4 | 5 | #ifndef STORAGE_LEVELDB_INCLUDE_DUMPFILE_H_ 6 | #define STORAGE_LEVELDB_INCLUDE_DUMPFILE_H_ 7 | 8 | #include 9 | #include "leveldb/env.h" 10 | #include "leveldb/status.h" 11 | 12 | namespace leveldb { 13 | 14 | // Dump the contents of the file named by fname in text format to 15 | // *dst. Makes a sequence of dst->Append() calls; each call is passed 16 | // the newline-terminated text corresponding to a single item found 17 | // in the file. 18 | // 19 | // Returns a non-OK result if fname does not name a leveldb storage 20 | // file, or if the file cannot be read. 21 | Status DumpFile(Env* env, const std::string& fname, WritableFile* dst); 22 | 23 | } // namespace leveldb 24 | 25 | #endif // STORAGE_LEVELDB_INCLUDE_DUMPFILE_H_ 26 | -------------------------------------------------------------------------------- /include/miniupnpc/LICENSE: -------------------------------------------------------------------------------- 1 | MiniUPnPc 2 | Copyright (c) 2005-2011, Thomas BERNARD 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | * The name of the author may not be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 20 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 | POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /include/miniupnpc/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README 2 | include miniupnpcmodule.c 3 | include setup.py 4 | include *.h 5 | include libminiupnpc.a 6 | -------------------------------------------------------------------------------- /include/miniupnpc/VERSION: -------------------------------------------------------------------------------- 1 | 1.7 2 | -------------------------------------------------------------------------------- /include/miniupnpc/codelength.h: -------------------------------------------------------------------------------- 1 | /* $Id: codelength.h,v 1.3 2011/07/30 13:10:05 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas BERNARD 4 | * copyright (c) 2005-2011 Thomas Bernard 5 | * This software is subjet to the conditions detailed in the 6 | * provided LICENCE file. */ 7 | #ifndef __CODELENGTH_H__ 8 | #define __CODELENGTH_H__ 9 | 10 | /* Encode length by using 7bit per Byte : 11 | * Most significant bit of each byte specifies that the 12 | * following byte is part of the code */ 13 | #define DECODELENGTH(n, p) n = 0; \ 14 | do { n = (n << 7) | (*p & 0x7f); } \ 15 | while((*(p++)&0x80) && (n<(1<<25))); 16 | 17 | #define DECODELENGTH_CHECKLIMIT(n, p, p_limit) \ 18 | n = 0; \ 19 | do { \ 20 | if((p) >= (p_limit)) break; \ 21 | n = (n << 7) | (*(p) & 0x7f); \ 22 | } while((*((p)++)&0x80) && (n<(1<<25))); 23 | 24 | #define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ 25 | if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ 26 | if(n>=16384) *(p++) = (n >> 14) | 0x80; \ 27 | if(n>=128) *(p++) = (n >> 7) | 0x80; \ 28 | *(p++) = n & 0x7f; 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /include/miniupnpc/connecthostport.h: -------------------------------------------------------------------------------- 1 | /* $Id: connecthostport.h,v 1.2 2012/06/23 22:32:33 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2010-2012 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef __CONNECTHOSTPORT_H__ 9 | #define __CONNECTHOSTPORT_H__ 10 | 11 | /* connecthostport() 12 | * return a socket connected (TCP) to the host and port 13 | * or -1 in case of error */ 14 | int connecthostport(const char * host, unsigned short port, 15 | unsigned int scope_id); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /include/miniupnpc/declspec.h: -------------------------------------------------------------------------------- 1 | #ifndef __DECLSPEC_H__ 2 | #define __DECLSPEC_H__ 3 | 4 | #if defined(_WIN32) && !defined(STATICLIB) 5 | #ifdef MINIUPNP_EXPORTS 6 | #define LIBSPEC __declspec(dllexport) 7 | #else 8 | #define LIBSPEC __declspec(dllimport) 9 | #endif 10 | #else 11 | #define LIBSPEC 12 | #endif 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /include/miniupnpc/external-ip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: external-ip.sh,v 1.1 2010/08/05 12:57:41 nanard Exp $ 3 | # (c) 2010 Reuben Hawkins 4 | upnpc -s | grep ExternalIPAddress | sed 's/[^0-9\.]//g' 5 | -------------------------------------------------------------------------------- /include/miniupnpc/mingw32make.bat: -------------------------------------------------------------------------------- 1 | @mingw32-make -f Makefile.mingw %1 2 | @if errorlevel 1 goto end 3 | @if not exist upnpc-static.exe goto end 4 | @strip upnpc-static.exe 5 | @upx --best upnpc-static.exe 6 | @strip upnpc-shared.exe 7 | @upx --best upnpc-shared.exe 8 | :end 9 | -------------------------------------------------------------------------------- /include/miniupnpc/minisoap.h: -------------------------------------------------------------------------------- 1 | /* $Id: minisoap.h,v 1.4 2010/04/12 20:39:41 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2005 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. */ 7 | #ifndef __MINISOAP_H__ 8 | #define __MINISOAP_H__ 9 | 10 | /*int httpWrite(int, const char *, int, const char *);*/ 11 | int soapPostSubmit(int, const char *, const char *, unsigned short, 12 | const char *, const char *, const char *); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /include/miniupnpc/minissdpc.h: -------------------------------------------------------------------------------- 1 | /* $Id: minissdpc.h,v 1.1 2007/08/31 15:15:33 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2007 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef __MINISSDPC_H__ 9 | #define __MINISSDPC_H__ 10 | 11 | struct UPNPDev * 12 | getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath); 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /include/miniupnpc/miniupnpc.def: -------------------------------------------------------------------------------- 1 | LIBRARY 2 | ; miniupnpc library 3 | 4 | EXPORTS 5 | ; miniupnpc 6 | upnpDiscover 7 | freeUPNPDevlist 8 | parserootdesc 9 | UPNP_GetValidIGD 10 | UPNP_GetIGDFromUrl 11 | GetUPNPUrls 12 | FreeUPNPUrls 13 | ; miniwget 14 | miniwget 15 | miniwget_getaddr 16 | ; upnpcommands 17 | UPNP_GetTotalBytesSent 18 | UPNP_GetTotalBytesReceived 19 | UPNP_GetTotalPacketsSent 20 | UPNP_GetTotalPacketsReceived 21 | UPNP_GetStatusInfo 22 | UPNP_GetConnectionTypeInfo 23 | UPNP_GetExternalIPAddress 24 | UPNP_GetLinkLayerMaxBitRates 25 | UPNP_AddPortMapping 26 | UPNP_DeletePortMapping 27 | UPNP_GetPortMappingNumberOfEntries 28 | UPNP_GetSpecificPortMappingEntry 29 | UPNP_GetGenericPortMappingEntry 30 | UPNP_GetListOfPortMappings 31 | UPNP_AddPinhole 32 | UPNP_CheckPinholeWorking 33 | UPNP_UpdatePinhole 34 | UPNP_GetPinholePackets 35 | UPNP_DeletePinhole 36 | UPNP_GetFirewallStatus 37 | UPNP_GetOutboundPinholeTimeout 38 | ; upnperrors 39 | strupnperror 40 | ; portlistingparse 41 | ParsePortListing 42 | FreePortListing 43 | -------------------------------------------------------------------------------- /include/miniupnpc/miniupnpcstrings.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef __MINIUPNPCSTRINGS_H__ 2 | #define __MINIUPNPCSTRINGS_H__ 3 | 4 | #define OS_STRING "${CMAKE_SYSTEM_NAME}" 5 | #define MINIUPNPC_VERSION_STRING "${MINIUPNPC_VERSION}" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/miniupnpc/miniupnpcstrings.h.in: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpcstrings.h.in,v 1.4 2011/01/04 11:41:53 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2005-2011 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef __MINIUPNPCSTRINGS_H__ 9 | #define __MINIUPNPCSTRINGS_H__ 10 | 11 | #define OS_STRING "OS/version" 12 | #define MINIUPNPC_VERSION_STRING "version" 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /include/miniupnpc/miniupnpctypes.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniupnpctypes.h,v 1.1 2011/02/15 11:10:40 nanard Exp $ */ 2 | /* Miniupnp project : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2011 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided within this distribution */ 7 | #ifndef __MINIUPNPCTYPES_H__ 8 | #define __MINIUPNPCTYPES_H__ 9 | 10 | #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) 11 | #define UNSIGNED_INTEGER unsigned long long 12 | #define STRTOUI strtoull 13 | #else 14 | #define UNSIGNED_INTEGER unsigned int 15 | #define STRTOUI strtoul 16 | #endif 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /include/miniupnpc/miniwget.h: -------------------------------------------------------------------------------- 1 | /* $Id: miniwget.h,v 1.7 2012/06/23 22:35:59 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2005-2012 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. 7 | * */ 8 | #ifndef __MINIWGET_H__ 9 | #define __MINIWGET_H__ 10 | 11 | #include "declspec.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | LIBSPEC void * getHTTPResponse(int s, int * size); 18 | 19 | LIBSPEC void * miniwget(const char *, int *, unsigned int); 20 | 21 | LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int, unsigned int); 22 | 23 | int parseURL(const char *, char *, unsigned short *, char * *, unsigned int *); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /include/miniupnpc/minixml.h: -------------------------------------------------------------------------------- 1 | /* $Id: minixml.h,v 1.6 2006/11/30 11:47:21 nanard Exp $ */ 2 | /* minimal xml parser 3 | * 4 | * Project : miniupnp 5 | * Website : http://miniupnp.free.fr/ 6 | * Author : Thomas Bernard 7 | * Copyright (c) 2005 Thomas Bernard 8 | * This software is subject to the conditions detailed in the 9 | * LICENCE file provided in this distribution. 10 | * */ 11 | #ifndef __MINIXML_H__ 12 | #define __MINIXML_H__ 13 | #define IS_WHITE_SPACE(c) ((c==' ') || (c=='\t') || (c=='\r') || (c=='\n')) 14 | 15 | /* if a callback function pointer is set to NULL, 16 | * the function is not called */ 17 | struct xmlparser { 18 | const char *xmlstart; 19 | const char *xmlend; 20 | const char *xml; /* pointer to current character */ 21 | int xmlsize; 22 | void * data; 23 | void (*starteltfunc) (void *, const char *, int); 24 | void (*endeltfunc) (void *, const char *, int); 25 | void (*datafunc) (void *, const char *, int); 26 | void (*attfunc) (void *, const char *, int, const char *, int); 27 | }; 28 | 29 | /* parsexml() 30 | * the xmlparser structure must be initialized before the call 31 | * the following structure members have to be initialized : 32 | * xmlstart, xmlsize, data, *func 33 | * xml is for internal usage, xmlend is computed automatically */ 34 | void parsexml(struct xmlparser *); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /include/miniupnpc/portlistingparse.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Achain-Dev/Achain_linux/8c6daad526c84fa513f119206e45f62eb68b8a86/include/miniupnpc/portlistingparse.o -------------------------------------------------------------------------------- /include/miniupnpc/pymoduletest.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # MiniUPnP project 3 | # Author : Thomas Bernard 4 | # This Sample code is public domain. 5 | # website : http://miniupnp.tuxfamily.org/ 6 | 7 | # import the python miniupnpc module 8 | import miniupnpc 9 | import sys 10 | 11 | # create the object 12 | u = miniupnpc.UPnP() 13 | print 'inital(default) values :' 14 | print ' discoverdelay', u.discoverdelay 15 | print ' lanaddr', u.lanaddr 16 | print ' multicastif', u.multicastif 17 | print ' minissdpdsocket', u.minissdpdsocket 18 | u.discoverdelay = 200; 19 | #u.minissdpdsocket = '../minissdpd/minissdpd.sock' 20 | # discovery process, it usualy takes several seconds (2 seconds or more) 21 | print 'Discovering... delay=%ums' % u.discoverdelay 22 | print u.discover(), 'device(s) detected' 23 | # select an igd 24 | try: 25 | u.selectigd() 26 | except Exception, e: 27 | print 'Exception :', e 28 | sys.exit(1) 29 | # display information about the IGD and the internet connection 30 | print 'local ip address :', u.lanaddr 31 | print 'external ip address :', u.externalipaddress() 32 | print u.statusinfo(), u.connectiontype() 33 | 34 | #print u.addportmapping(64000, 'TCP', 35 | # '192.168.1.166', 63000, 'port mapping test', '') 36 | #print u.deleteportmapping(64000, 'TCP') 37 | 38 | port = 0 39 | proto = 'UDP' 40 | # list the redirections : 41 | i = 0 42 | while True: 43 | p = u.getgenericportmapping(i) 44 | if p==None: 45 | break 46 | print i, p 47 | (port, proto, (ihost,iport), desc, c, d, e) = p 48 | #print port, desc 49 | i = i + 1 50 | 51 | print u.getspecificportmapping(port, proto) 52 | 53 | -------------------------------------------------------------------------------- /include/miniupnpc/receivedata.h: -------------------------------------------------------------------------------- 1 | /* $Id: receivedata.h,v 1.3 2012/06/23 22:34:47 nanard Exp $ */ 2 | /* Project: miniupnp 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * Author: Thomas Bernard 5 | * Copyright (c) 2011-2012 Thomas Bernard 6 | * This software is subjects to the conditions detailed 7 | * in the LICENCE file provided within this distribution */ 8 | #ifndef __RECEIVEDATA_H__ 9 | #define __RECEIVEDATA_H__ 10 | 11 | /* Reads data from the specified socket. 12 | * Returns the number of bytes read if successful, zero if no bytes were 13 | * read or if we timed out. Returns negative if there was an error. */ 14 | int receivedata(int socket, 15 | char * data, int length, 16 | int timeout, unsigned int * scope_id); 17 | 18 | #endif 19 | 20 | -------------------------------------------------------------------------------- /include/miniupnpc/setup.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # $Id: setup.py,v 1.9 2012/05/23 08:50:10 nanard Exp $ 3 | # the MiniUPnP Project (c) 2007-2012 Thomas Bernard 4 | # http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/ 5 | # 6 | # python script to build the miniupnpc module under unix 7 | # 8 | # replace libminiupnpc.a by libminiupnpc.so for shared library usage 9 | from distutils.core import setup, Extension 10 | from distutils import sysconfig 11 | sysconfig.get_config_vars()["OPT"] = '' 12 | sysconfig.get_config_vars()["CFLAGS"] = '' 13 | setup(name="miniupnpc", version="1.7", 14 | ext_modules=[ 15 | Extension(name="miniupnpc", sources=["miniupnpcmodule.c"], 16 | extra_objects=["libminiupnpc.a"]) 17 | ]) 18 | 19 | -------------------------------------------------------------------------------- /include/miniupnpc/setupmingw32.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/python 2 | # $Id: setupmingw32.py,v 1.8 2012/05/23 08:50:10 nanard Exp $ 3 | # the MiniUPnP Project (c) 2007-2012 Thomas Bernard 4 | # http://miniupnp.tuxfamily.org/ or http://miniupnp.free.fr/ 5 | # 6 | # python script to build the miniupnpc module under windows (using mingw32) 7 | # 8 | from distutils.core import setup, Extension 9 | from distutils import sysconfig 10 | sysconfig.get_config_vars()["OPT"] = '' 11 | sysconfig.get_config_vars()["CFLAGS"] = '' 12 | setup(name="miniupnpc", version="1.7", 13 | ext_modules=[ 14 | Extension(name="miniupnpc", sources=["miniupnpcmodule.c"], 15 | libraries=["ws2_32", "iphlpapi"], 16 | extra_objects=["libminiupnpc.a"]) 17 | ]) 18 | 19 | -------------------------------------------------------------------------------- /include/miniupnpc/testminiwget.c: -------------------------------------------------------------------------------- 1 | /* $Id: testminiwget.c,v 1.4 2012/06/23 22:35:59 nanard Exp $ */ 2 | /* Project : miniupnp 3 | * Author : Thomas Bernard 4 | * Copyright (c) 2005-2012 Thomas Bernard 5 | * This software is subject to the conditions detailed in the 6 | * LICENCE file provided in this distribution. 7 | * */ 8 | #include 9 | #include 10 | #include "miniwget.h" 11 | 12 | /** 13 | * This program uses the miniwget / miniwget_getaddr function 14 | * from miniwget.c in order to retreive a web ressource using 15 | * a GET HTTP method, and store it in a file. 16 | */ 17 | int main(int argc, char * * argv) 18 | { 19 | void * data; 20 | int size, writtensize; 21 | FILE *f; 22 | char addr[64]; 23 | 24 | if(argc < 3) { 25 | fprintf(stderr, "Usage:\t%s url file\n", argv[0]); 26 | fprintf(stderr, "Example:\t%s http://www.google.com/ out.html\n", argv[0]); 27 | return 1; 28 | } 29 | data = miniwget_getaddr(argv[1], &size, addr, sizeof(addr), 0); 30 | if(!data) { 31 | fprintf(stderr, "Error fetching %s\n", argv[1]); 32 | return 1; 33 | } 34 | printf("local address : %s\n", addr); 35 | printf("got %d bytes\n", size); 36 | f = fopen(argv[2], "wb"); 37 | if(!f) { 38 | fprintf(stderr, "Cannot open file %s for writing\n", argv[2]); 39 | free(data); 40 | return 1; 41 | } 42 | writtensize = fwrite(data, 1, size, f); 43 | if(writtensize != size) { 44 | fprintf(stderr, "Could only write %d bytes out of %d to %s\n", 45 | writtensize, size, argv[2]); 46 | } else { 47 | printf("%d bytes written to %s\n", writtensize, argv[2]); 48 | } 49 | fclose(f); 50 | free(data); 51 | return 0; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /include/miniupnpc/testupnpreplyparse.c: -------------------------------------------------------------------------------- 1 | /* $Id: testupnpreplyparse.c,v 1.2 2008/02/21 13:05:27 nanard Exp $ */ 2 | /* MiniUPnP project 3 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 4 | * (c) 2006-2007 Thomas Bernard 5 | * This software is subject to the conditions detailed 6 | * in the LICENCE file provided within the distribution */ 7 | #include 8 | #include 9 | #include "upnpreplyparse.h" 10 | 11 | void 12 | test_parsing(const char * buf, int len) 13 | { 14 | struct NameValueParserData pdata; 15 | ParseNameValue(buf, len, &pdata); 16 | ClearNameValueList(&pdata); 17 | } 18 | 19 | int main(int argc, char * * argv) 20 | { 21 | FILE * f; 22 | char buffer[4096]; 23 | int l; 24 | if(argc<2) 25 | { 26 | fprintf(stderr, "Usage: %s file.xml\n", argv[0]); 27 | return 1; 28 | } 29 | f = fopen(argv[1], "r"); 30 | if(!f) 31 | { 32 | fprintf(stderr, "Error : can not open file %s\n", argv[1]); 33 | return 2; 34 | } 35 | l = fread(buffer, 1, sizeof(buffer)-1, f); 36 | fclose(f); 37 | buffer[l] = '\0'; 38 | #ifdef DEBUG 39 | DisplayNameValueList(buffer, l); 40 | #endif 41 | test_parsing(buffer, l); 42 | return 0; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /include/miniupnpc/upnperrors.h: -------------------------------------------------------------------------------- 1 | /* $Id: upnperrors.h,v 1.3 2012/03/05 19:42:47 nanard Exp $ */ 2 | /* (c) 2007 Thomas Bernard 3 | * All rights reserved. 4 | * MiniUPnP Project. 5 | * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ 6 | * This software is subjet to the conditions detailed in the 7 | * provided LICENCE file. */ 8 | #ifndef __UPNPERRORS_H__ 9 | #define __UPNPERRORS_H__ 10 | 11 | #include "declspec.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /* strupnperror() 18 | * Return a string description of the UPnP error code 19 | * or NULL for undefinded errors */ 20 | LIBSPEC const char * strupnperror(int err); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif 27 | --------------------------------------------------------------------------------