From 5702659b0daea099854879f07431d5f7d353540c Mon Sep 17 00:00:00 2001 From: yiqun Date: Sat, 8 Feb 2025 14:04:52 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=90=88=E7=BA=A6=E6=94=BE=E5=88=B0json?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E9=81=BF=E5=85=8D=E9=87=8D=E5=A4=8D=E4=B8=8A?= =?UTF-8?q?=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/process_logic.py | 32 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/python-fisco-console/process_logic.py b/python-fisco-console/process_logic.py index 4fc9255..e429ca9 100644 --- a/python-fisco-console/process_logic.py +++ b/python-fisco-console/process_logic.py @@ -47,12 +47,35 @@ def get_to_address(): print("new address : ", result["contractAddress"]) contract_name = os.path.splitext(os.path.basename(abi_file))[0] - # todo 可以放入缓存中 以合约名为key,不需要每次重启都部署合约,每次部署合约会添加一次交易。 to_address = result['contractAddress'] #use new deploy address # to_address = "0xcda895ec53a73fbc3777648cb4c87b38e252f876" #use new deploy address + return to_address, contract_abi, result + +def check_contract(): + """ + 通过 json文件 ,检查合约是否已经部署过,如果没有,则部署一次并生成json文件 + :return: + """ + if os.path.isfile('contracts.json'): + with open('contracts.json', 'r') as load_f: + load_data = json.load(load_f) + to_address, contract_abi, result = load_data['to_address'], load_data['contract_abi'], load_data['result'] + try: + get_transaction_detail_data(result['transactionHash']) + except Exception: + print("\n>>check fail") + os.remove('contracts.json') + check_contract() + else: + to_address, contract_abi, result = get_to_address() + with open('contracts.json', 'w') as save_f: + json.dump({ + 'to_address': to_address, + 'contract_abi': contract_abi, + 'result': result, + }, save_f) return to_address, contract_abi - def get_one_block(res): number = int(res.get("number"), 16) add_time = time.strftime("%Y-%m-%d %H:%M:%S", @@ -293,7 +316,6 @@ def get_block_detail_data(blockHash): def send_transaction_get_txhash(requestData): - to_address, contract_abi = get_to_address() # requestData = json.loads(request.get_data().decode()) hash = hashlib.sha1() hash.update(json.dumps(requestData, ensure_ascii=False).encode('utf-8')) @@ -305,4 +327,6 @@ def send_transaction_get_txhash(requestData): receipt = client.sendRawTransactionGetReceipt(to_address, contract_abi, "set", args) txhash = receipt['transactionHash'] # print("receipt:",receipt) - return txhash \ No newline at end of file + return txhash + +to_address, contract_abi = check_contract() From 303907c613d20661e389c865d0d17cefb6ad17b3 Mon Sep 17 00:00:00 2001 From: yiqun Date: Sat, 8 Feb 2025 16:08:36 +0800 Subject: [PATCH 02/19] =?UTF-8?q?tornado=E4=B8=8D=E8=83=BD=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E9=A6=96=E9=A1=B5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/fisco_browser_tornado.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-fisco-console/fisco_browser_tornado.py b/python-fisco-console/fisco_browser_tornado.py index feb240f..eae5f8d 100644 --- a/python-fisco-console/fisco_browser_tornado.py +++ b/python-fisco-console/fisco_browser_tornado.py @@ -65,7 +65,7 @@ def __init__(self): handlers = [ (r'/sendTrans/(.*)', TransHandler), (r'/query_info/(.*)', QueryHandler), - (r"/", tornado.web.RedirectHandler, {"url": "/index.html"}), + (r"/", tornado.web.RedirectHandler, {"url": "/static/index.html"}), ] settings = dict( From 805fa63fd12e1a238bcc1db92effc2a7f88a74d7 Mon Sep 17 00:00:00 2001 From: yiqun Date: Mon, 10 Feb 2025 13:38:48 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=81=E4=B9=85?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 12 +++++++ README.md | 50 +++++++++++++-------------- python-fisco-console/process_logic.py | 9 ++--- run.sh | 2 ++ 4 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 Dockerfile create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aaac2c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM fiscoorg/playground:python_sdk + +WORKDIR /python-sdk + +RUN pip install flask==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir + +COPY . /python-sdk +RUN mv python-fisco-console/* /python-sdk + +EXPOSE 20200 30300 8545 5555 + +CMD ["bash", "run.sh"] \ No newline at end of file diff --git a/README.md b/README.md index f59e26b..aba7536 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,12 @@ # FiscoBcos-PyConsole -FiscoBcos 的区块链浏览器 +FiscoBcos 的区块链浏览器,自带上链以及查询 rest-api ### 简介 -基于python-sdk开发的区块链浏览器,页面参考原始的区块链浏览器 +基于python-sdk开发的区块链浏览器,自带 restFul API 接口,无须 Java、MySQL ``` https://github.com/FISCO-BCOS/fisco-bcos-browser.git ``` -点击进入原始 [区块链浏览器](https://github.com/FISCO-BCOS/fisco-bcos-browser.git) -本工程只需要Python3.5 + 即可 - -原始工程需要Python2.7, Java, 以及MySQL.因此进行了简化,不需要任何数据库 #### 项目效果 首页 @@ -21,30 +17,23 @@ https://github.com/FISCO-BCOS/fisco-bcos-browser.git ![首页截图](https://github.com/Wall-ee/FiscoBcos-PyConsole/blob/master/transaction_detail.png) -### 环境要求 -1. Fisco Bcos 网络配置完毕 -2. Python3.5+ -3. Flask/Tornado安装 -4. 安装Fisco Bcos 的Python-SDK -``` -https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/python_sdk/install.html -``` -点击进入[Python SDK](https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/python_sdk/install.html) -轻量级Python的Http服务器--Flask [官方文档](https://flask.palletsprojects.com/en/master/) -高性能异步非阻塞Python服务器(FaceBook开源)--Tornado [官方文档](http://www.tornadoweb.org/en/stable/) -### 使用方法 - -1. 安装Fisco Bcos的python-sdk,python-sdk配置规则参照官方教程; +### 使用 docker 快速运行 -2. 将python-fisco-consle下面的所有文件与文件夹一并复制放入python-sdk根目录。其中包括static静态页面目录,以及flask和tornado 的启动文件; +```shell +docker run -p 5555:5555 -d --mount type=volume,source=fisco,target=/root/fisco fisco_webserve +``` -3. 启动fisco_browser_flask.py 或 fisco_browser_tornado.py 则分别启动flask/tornado 的工程; +主页访问地址: http://ip:5555/index.html -4. flask主页访问地址: http:ip:5555/index.html +通过 API 接口上链一条数据 +```shell +curl --location 'http://127.0.0.1:5555/sendTrans/rawTrans' \ +--header 'Content-Type: application/json' \ +--data '{"data": "cross the world"}' +``` - tornado主页访问地址: http:ip:5555 或 http:ip:5555/static/index.html ### 区块链浏览器的api详解: @@ -55,7 +44,7 @@ https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/python_sdk 5. 每次部署合约都会生成一个区块,区块内包含一个交易。 -### API详解: +### API 接口: >GET 查询api: @@ -71,4 +60,13 @@ https://fisco-bcos-documentation.readthedocs.io/zh_CN/latest/docs/sdk/python_sdk >POST 上传交易api: -/sendTrans/rawTrans 上传json格式数据,发送交易上链 \ No newline at end of file +/sendTrans/rawTrans 上传json格式数据,发送交易上链 + + +### 开发原理 + +1. 安装Fisco Bcos的python-sdk,python-sdk配置规则参照官方教程; + +2. 将python-fisco-consle下面的所有文件与文件夹一并复制放入python-sdk根目录。其中包括static静态页面目录,以及flask和tornado 的启动文件; + +3. 启动fisco_browser_flask.py 或 fisco_browser_tornado.py 则分别启动flask/tornado 的工程; diff --git a/python-fisco-console/process_logic.py b/python-fisco-console/process_logic.py index e429ca9..7d5e4f3 100644 --- a/python-fisco-console/process_logic.py +++ b/python-fisco-console/process_logic.py @@ -56,19 +56,20 @@ def check_contract(): 通过 json文件 ,检查合约是否已经部署过,如果没有,则部署一次并生成json文件 :return: """ - if os.path.isfile('contracts.json'): - with open('contracts.json', 'r') as load_f: + file_path = '/root/fisco/nodes/contracts.json' + if os.path.isfile(file_path): + with open(file_path, 'r') as load_f: load_data = json.load(load_f) to_address, contract_abi, result = load_data['to_address'], load_data['contract_abi'], load_data['result'] try: get_transaction_detail_data(result['transactionHash']) except Exception: print("\n>>check fail") - os.remove('contracts.json') + os.remove(file_path) check_contract() else: to_address, contract_abi, result = get_to_address() - with open('contracts.json', 'w') as save_f: + with open(file_path, 'w') as save_f: json.dump({ 'to_address': to_address, 'contract_abi': contract_abi, diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..55ccd09 --- /dev/null +++ b/run.sh @@ -0,0 +1,2 @@ +bash /root/fisco/nodes/127.0.0.1/start_all.sh +python /python-sdk/fisco_browser_flask.py \ No newline at end of file From 387e7b12138e67462c9be0a9addb7e3c30c4e656 Mon Sep 17 00:00:00 2001 From: yiqun Date: Mon, 10 Feb 2025 13:56:19 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=9B=B4=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index aba7536..7dd5ceb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# FiscoBcos-PyConsole -FiscoBcos 的区块链浏览器,自带上链以及查询 rest-api +# FiscoBcos-Box +FiscoBcos 的区块链盒子,包含 WEB 查看页面, 以及 restFul API ### 简介 -基于python-sdk开发的区块链浏览器,自带 restFul API 接口,无须 Java、MySQL +基于FiscoBcos python-sdk 开发的区块链浏览器,自带 restFul API 接口,无须 Java、MySQL ``` https://github.com/FISCO-BCOS/fisco-bcos-browser.git ``` @@ -11,18 +11,18 @@ https://github.com/FISCO-BCOS/fisco-bcos-browser.git #### 项目效果 首页 -![首页截图](https://github.com/Wall-ee/FiscoBcos-PyConsole/blob/master/index.png) +![首页截图](https://github.com/Wall-ee/FiscoBcos-Box/blob/master/index.png) 交易详情 -![首页截图](https://github.com/Wall-ee/FiscoBcos-PyConsole/blob/master/transaction_detail.png) +![首页截图](https://github.com/Wall-ee/FiscoBcos-Box/blob/master/transaction_detail.png) ### 使用 docker 快速运行 ```shell -docker run -p 5555:5555 -d --mount type=volume,source=fisco,target=/root/fisco fisco_webserve +docker run -p 5555:5555 -d --mount type=volume,source=fisco,target=/root/fisco shujuliuer/fisco_box ``` 主页访问地址: http://ip:5555/index.html From 9954ced5ae4da1bfcfa07570b640dc7e2e106901 Mon Sep 17 00:00:00 2001 From: yiqun Date: Mon, 10 Feb 2025 13:58:15 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7dd5ceb..d0157ef 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ https://github.com/FISCO-BCOS/fisco-bcos-browser.git #### 项目效果 首页 -![首页截图](https://github.com/Wall-ee/FiscoBcos-Box/blob/master/index.png) +![首页截图](https://github.com/horizon365/FiscoBcos-Box/blob/master/index.png) 交易详情 -![首页截图](https://github.com/Wall-ee/FiscoBcos-Box/blob/master/transaction_detail.png) +![首页截图](https://github.com/horizon365/FiscoBcos-Box/blob/master/transaction_detail.png) From f38e4653c3dec2c2c7936bbf5ac29b02fafae15b Mon Sep 17 00:00:00 2001 From: yiqun Date: Tue, 11 Feb 2025 14:15:37 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djs=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/static/block_detail.html | 2 +- python-fisco-console/static/transaction_detail.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python-fisco-console/static/block_detail.html b/python-fisco-console/static/block_detail.html index e8cad3e..97a7710 100644 --- a/python-fisco-console/static/block_detail.html +++ b/python-fisco-console/static/block_detail.html @@ -12,7 +12,7 @@ - + diff --git a/python-fisco-console/static/transaction_detail.html b/python-fisco-console/static/transaction_detail.html index 310b598..0ec3ea1 100644 --- a/python-fisco-console/static/transaction_detail.html +++ b/python-fisco-console/static/transaction_detail.html @@ -12,7 +12,7 @@ - + From 2079b7fc8e9f82d0a2bf3bddb328f36950abb48d Mon Sep 17 00:00:00 2001 From: yiqun Date: Tue, 11 Feb 2025 15:37:27 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djs=E7=BC=93=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/static/block_detail.html | 2 +- python-fisco-console/static/block_list.html | 4 ++-- python-fisco-console/static/index.html | 4 ++-- python-fisco-console/static/transaction_detail.html | 2 +- python-fisco-console/static/transaction_list.html | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python-fisco-console/static/block_detail.html b/python-fisco-console/static/block_detail.html index 97a7710..09853a8 100644 --- a/python-fisco-console/static/block_detail.html +++ b/python-fisco-console/static/block_detail.html @@ -9,7 +9,7 @@ 区块详情 - + diff --git a/python-fisco-console/static/block_list.html b/python-fisco-console/static/block_list.html index cb4067f..ccbb432 100644 --- a/python-fisco-console/static/block_list.html +++ b/python-fisco-console/static/block_list.html @@ -9,10 +9,10 @@ 区块列表 - + - +
diff --git a/python-fisco-console/static/index.html b/python-fisco-console/static/index.html index 83ac443..7f5af5c 100644 --- a/python-fisco-console/static/index.html +++ b/python-fisco-console/static/index.html @@ -8,8 +8,8 @@ 首页 - - + + diff --git a/python-fisco-console/static/transaction_detail.html b/python-fisco-console/static/transaction_detail.html index 0ec3ea1..a869026 100644 --- a/python-fisco-console/static/transaction_detail.html +++ b/python-fisco-console/static/transaction_detail.html @@ -9,7 +9,7 @@ 交易详情 - + diff --git a/python-fisco-console/static/transaction_list.html b/python-fisco-console/static/transaction_list.html index 3b833f0..2a04320 100644 --- a/python-fisco-console/static/transaction_list.html +++ b/python-fisco-console/static/transaction_list.html @@ -202,10 +202,10 @@ - + - +
From b1ad2877f18d1cadfb3cc84014ddb902739c2146 Mon Sep 17 00:00:00 2001 From: yiqun Date: Wed, 12 Feb 2025 14:28:02 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0get=5Fsummary=5Fdata?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/fisco_browser_flask.py | 10 +++- python-fisco-console/process_logic.py | 56 +++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/python-fisco-console/fisco_browser_flask.py b/python-fisco-console/fisco_browser_flask.py index c1f8c75..fc3fc83 100644 --- a/python-fisco-console/fisco_browser_flask.py +++ b/python-fisco-console/fisco_browser_flask.py @@ -7,7 +7,8 @@ get_transaction_detail_data, send_transaction_get_txhash, get_block_detail_data, - get_data_parser + get_data_parser, + get_summary_data ) app = Flask(__name__, @@ -67,6 +68,13 @@ def send_transaction(): # print("receipt:",receipt) return txhash +# 获取区块以及交易的混合信息 +@app.route('/query_info/get_summary_data', methods=['GET']) +def get_transaction(): + transactionHash = request.args.get('transactionHash', '') + data = get_summary_data(transactionHash) + return json.dumps(data) + if __name__ == "__main__": app.run(port=5555, debug=True, host="0.0.0.0") diff --git a/python-fisco-console/process_logic.py b/python-fisco-console/process_logic.py index 7d5e4f3..133707f 100644 --- a/python-fisco-console/process_logic.py +++ b/python-fisco-console/process_logic.py @@ -284,6 +284,62 @@ def get_transaction_list_data(blockNumber, transactionHash, page): } return result +def get_block_hash(blockNumber, blockHash): + block_hash = number = add_time = transaction_number ='--' + try: + block_list = get_block_list_data(blockNumber, blockHash, '')['block_list'] + except: + pass + else: + block_hash = block_list[0]['block_hash'] + number = block_list[0]['number'] + add_time = block_list[0]['add_time'] + transaction_number = block_list[0]['transaction_num'] + return block_hash, number, add_time, transaction_number + +def get_summary_data(transactionHash): + """ +返回值为: +区块信息 + 当前区块(Current block) + 当前区块交易数量(Current block transactions) + 区块哈希值(Block hash) + 前一个区块哈希(Previous block hash) + 后一个区块哈希(Latter block hash) + 区块创建时间(Block creation time) +交易信息 + 交易哈希值(Transaction hash) + 发送者(from):加密 + 接收者(to):加密 + 输入信息(Input):加密 + 交易创建时间(Transaction create time) + +""" + transaction_detail = get_transaction_detail_data(transactionHash) + receipt = transaction_detail['transactionReceipt'] + block_hash = receipt['blockHash'] + block_detail = get_block_detail_data(block_hash) + _, block_number, add_time, transaction_number = get_block_hash('', block_hash) + + data = { + 'block' : { + 'blockNumber': block_number, + 'transactionNumber': transaction_number, + 'blockHash': block_hash, + 'parentHash': block_detail['parentHash'], + 'childHash': get_block_hash(block_number+1, '')[0], + 'time': add_time, + + }, + 'transaction' : { + 'transactionHash': transactionHash, + 'from': receipt['from'], + 'to': receipt['to'], + 'input': receipt['input'], + 'time': get_transaction_list_data('',transactionHash, '')['transaction_list'][0]['time'], + } + } + return data def get_transaction_detail_data(transactionHash): # transactionHash = request.args.get('transactionHash', '') From 442b18c0fc35c03abd4652587439ae337d5a52cf Mon Sep 17 00:00:00 2001 From: yiqun Date: Wed, 12 Feb 2025 14:55:53 +0800 Subject: [PATCH 09/19] =?UTF-8?q?=E5=A2=9E=E5=8A=A0get=5Fsummary=5Fdata?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d0157ef..40e692a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,9 @@ curl --location 'http://127.0.0.1:5555/sendTrans/rawTrans' \ /query_info/transaction_detail 根据交易哈希,获取交易详情和交易回执 +/query_info/get_summary_data 根据交易哈希,获取区块详情(包括上一区块、下一区块)和交易详情 + + >POST 上传交易api: /sendTrans/rawTrans 上传json格式数据,发送交易上链 From d612ca39a5cb1a85832bcda0e3b03caca9c6d00e Mon Sep 17 00:00:00 2001 From: yiqun Date: Thu, 13 Feb 2025 14:15:51 +0800 Subject: [PATCH 10/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E7=99=BD=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/static/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-fisco-console/static/index.html b/python-fisco-console/static/index.html index 7f5af5c..9816a6c 100644 --- a/python-fisco-console/static/index.html +++ b/python-fisco-console/static/index.html @@ -126,7 +126,7 @@
- + @@ -156,7 +156,7 @@
- + From 8a196745315b7a8a63893a3486d3e011a68a7e58 Mon Sep 17 00:00:00 2001 From: yiqun Date: Mon, 24 Feb 2025 11:18:50 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=97=B6=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index aaac2c4..715cd6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM fiscoorg/playground:python_sdk WORKDIR /python-sdk +RUN apk add --no-cache tzdata && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime RUN pip install flask==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir @@ -9,4 +10,4 @@ RUN mv python-fisco-console/* /python-sdk EXPOSE 20200 30300 8545 5555 -CMD ["bash", "run.sh"] \ No newline at end of file +CMD ["bash", "run.sh"] From a691eb51954afa5ff059ae0fd64a95983d71f250 Mon Sep 17 00:00:00 2001 From: yiqun Date: Tue, 4 Mar 2025 10:38:20 +0800 Subject: [PATCH 12/19] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=BAgunicorn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 715cd6d..8d3374d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM fiscoorg/playground:python_sdk WORKDIR /python-sdk RUN apk add --no-cache tzdata && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -RUN pip install flask==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir +RUN pip install flask==2.2.5 gunicorn==23.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir COPY . /python-sdk RUN mv python-fisco-console/* /python-sdk diff --git a/run.sh b/run.sh index 55ccd09..ad35faf 100644 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ bash /root/fisco/nodes/127.0.0.1/start_all.sh -python /python-sdk/fisco_browser_flask.py \ No newline at end of file +gunicorn fisco_browser_flask:app -w 4 -b :5555 From b114ed3aec6746fb22502cfbe16a4a2d0662295c Mon Sep 17 00:00:00 2001 From: yiqun Date: Thu, 6 Mar 2025 11:50:59 +0800 Subject: [PATCH 13/19] =?UTF-8?q?=E8=A1=A5=E5=85=85=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- Dockerfile.bak | 35 +++++++++++++++++++++++++++++++++++ README_for_cngbdb.md | 20 ++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.bak create mode 100644 README_for_cngbdb.md diff --git a/Dockerfile b/Dockerfile index 8d3374d..97dfe80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM fiscoorg/playground:python_sdk WORKDIR /python-sdk RUN apk add --no-cache tzdata && ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime -RUN pip install flask==2.2.5 gunicorn==23.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir +RUN pip install flask==2.2.5 gunicorn==23.0.0 -i https://mirrors.aliyun.com/pypi/simple/ --no-cache-dir COPY . /python-sdk RUN mv python-fisco-console/* /python-sdk diff --git a/Dockerfile.bak b/Dockerfile.bak new file mode 100644 index 0000000..a42de3d --- /dev/null +++ b/Dockerfile.bak @@ -0,0 +1,35 @@ +FROM python:3.7-alpine + +ENV USER root + +ENV PATH /root/.local/bin/:$PATH + +RUN mkdir /python-sdk + +WORKDIR /python-sdk + +RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ + apk update && \ + apk add --no-cache gcc g++ python3 python3-dev py3-pip openssl bash linux-headers libffi-dev openssl-dev curl wget git + +RUN curl -LO https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/v2.9.1/build_chain.sh && chmod u+x build_chain.sh && \ + bash build_chain.sh -l "127.0.0.1:4" -p 30300,20200,8545 + +RUN git clone https://github.com/FISCO-BCOS/python-sdk.git && mv python-sdk/* /python-sdk + +RUN bash init_env.sh -i && \ + cp /python-sdk/nodes/127.0.0.1/sdk/* bin/ && \ + ln -s /root/.local/bin/register-python-argcomplete /bin/register-python-argcomplete && \ + echo "eval \"\$(register-python-argcomplete ./console.py)\"" >> ~/.bashrc && \ + echo "eval \"/python-sdk/nodes/127.0.0.1/start_all.sh\"" >> ~/.bashrc + +COPY requirements.txt /requirements.txt + +RUN pip install -r /requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir + +COPY . /python-sdk +RUN mv python-fisco-console/* /python-sdk + +EXPOSE 20200 30300 8545 5555 + +CMD ["bash", "run.sh"] \ No newline at end of file diff --git a/README_for_cngbdb.md b/README_for_cngbdb.md new file mode 100644 index 0000000..e8d427f --- /dev/null +++ b/README_for_cngbdb.md @@ -0,0 +1,20 @@ +Nginx 配置: +```nginx configuration +location /fisco/api/ { +proxy_pass http://127.0.0.1:9518/; +more_clear_headers 'Cache-Control'; +more_set_headers 'Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; +} + +``` + + +# 手动打包docker +docker build --platform linux/amd64 -t harbor.cngb.org/cngbdb/fisco_box . + +# 运行docker +docker run -p 9518:5555 -d --mount type=volume,source=fisco,target=/root/fisco --name fisco harbor.cngb.org/cngbdb/fisco_box:0306 +# 修改js中的硬地址,用来匹配nginx代理配置 +docker exec -it fisco sed -i 's/url: "/url: "\/fisco\/api/g' /python-sdk/static/js/*.js + + From bfbb3a35a59ab06bf9bfda0877d6e9ac970e4a67 Mon Sep 17 00:00:00 2001 From: yiqun Date: Thu, 6 Mar 2025 16:47:13 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/static/block_list.html | 6 +++--- python-fisco-console/static/transaction_list.html | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python-fisco-console/static/block_list.html b/python-fisco-console/static/block_list.html index ccbb432..a137c18 100644 --- a/python-fisco-console/static/block_list.html +++ b/python-fisco-console/static/block_list.html @@ -96,7 +96,7 @@
-
+
@@ -129,7 +129,7 @@
- +
@@ -204,4 +204,4 @@ - \ No newline at end of file + diff --git a/python-fisco-console/static/transaction_list.html b/python-fisco-console/static/transaction_list.html index 2a04320..dea47f6 100644 --- a/python-fisco-console/static/transaction_list.html +++ b/python-fisco-console/static/transaction_list.html @@ -291,7 +291,7 @@
-
+
@@ -331,7 +331,7 @@
- +
@@ -428,4 +428,4 @@ - \ No newline at end of file + From 63b06998e2a63ecb20e3a19d7782cce1307dd00d Mon Sep 17 00:00:00 2001 From: yiqun Date: Thu, 6 Mar 2025 16:52:12 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E5=88=A0=E9=99=A4logo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python-fisco-console/static/block_detail.html | 8 ++++---- python-fisco-console/static/block_list.html | 6 +++--- python-fisco-console/static/index.html | 8 ++++---- python-fisco-console/static/transaction_detail.html | 6 +++--- python-fisco-console/static/transaction_list.html | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/python-fisco-console/static/block_detail.html b/python-fisco-console/static/block_detail.html index 09853a8..5f40f46 100644 --- a/python-fisco-console/static/block_detail.html +++ b/python-fisco-console/static/block_detail.html @@ -23,9 +23,9 @@
- - - -
+
节点Id
+
当前块高
+
pbftView
+
节点状态