Newer
Older
# CellFrame SDK.Python v0.9-4 Example Application #0

alexey.stratulat
committed
from CellFrame.libCellFrame import *

alexey.stratulat
committed
tmp_dir = os.getcwd() + "/tmp"
var_dir = os.getcwd() + "/var"
json_string = """{
"modules": ["Crypto", "ServerCore", "Http", "HttpFolder", "GlobalDB", "Client", "HttpClientSimple", "Mempool",
"Chain", "Wallet", "ChainCSDag", "ChainCSDagPoa", "ChainCSDagPos", "GDB", "Net", "AppCliServer", "ChainNetSrv", "EncHttp",
"Stream", "StreamCtl", "HttpSimple", "StreamChChain", "StreamChChainNet", "StreamChChainNetSrv"],

alexey.stratulat
committed
"config_dir": \""""+tmp_dir+"""\",
"log_level": "L_DEBUG",
"application_name": \""""+app_name+"""\",
"file_name_log": \""""+var_dir+"/log/"+app_name+".log"+"""\"
},
"Stream" : {
"DebugDumpStreamHeaders": false
},
"ServerCore" : {
"thread_cnt": 0,
"conn": 0

alexey.stratulat
committed
},
"Configuration" : {
"general": {
"debug_mode": false,
"debug_dump_stream_headers": false,
"wallets_default": "default"
},
"server": {
"listen_address": "0.0.0.0",
},
"conserver": {
"enabled": true,
"listen_unix_socket_path": \""""+tmp_dir+"/node_cli"+"""\"
},
"resources": {
"threads_cnt": 0,
"pid_path": \""""+ var_dir+"/run/"+ app_name+".pid"+"""\" ,
"log_file": \""""+var_dir+"/log/"+ app_name+".log"+"""\",
"wallets_path": \""""+var_dir+"/lib/wallet" + """\",
"ca_folders": [ \""""+var_dir+"""/lib/ca\" ],
"dap_global_db_path": \""""+var_dir+"/lib/global_db"+"""\",
"dap_global_db_driver": "cdb"
},
"networks":{

alexey.stratulat
committed
"devnet": {

alexey.stratulat
committed
"id": "0xFF00000000000003",

alexey.stratulat
committed
"type": "development",
"node-role": "root",
"gdb_groups_prefix": "devnet"
},
"name_cfg_files": ["chain-gdb"],
"conf_files":{
"chain-gdb": {
"general": {
"id": "0xf00000000000000f",
"name": "gdb",
"consensus": "gdb",
"class": "gdb",
"datum_types": ["token", "emission", "shard", "ca", "transaction"]
},
"gdb":{
"celled": false
}
}
}
}
}

alexey.stratulat
committed
}
setLogLevel(DEBUG)

alexey.stratulat
committed
server_host_name = configGetItem("server", "listen_address")
server_port = int(configGetItem("server", "listen_port_tcp"))

alexey.stratulat
committed
sr = ServerCore.listen(server_host_name, server_port, 0)

alexey.stratulat
committed
Http.new(sr, app_name)
EncHttp.addProc(sr, "/enc_http")
Stream.addProcHttp(sr, "/stream")
StreamCtl.addProcHttp(sr, "/stream_ctl")
ev = Events()

alexey.stratulat
committed
ev.start()

alexey.stratulat
committed
logItNotice(app_name+" v0.1 runned on port "+str(server_port))

alexey.stratulat
committed
rc = ServerCore.loop(sr)