首页 > 解决方案 > SyntaxError:在区块链上扫描字符串文字错误时 EOL

问题描述

我对准备好的区块链网络进行了更改。我正在使用以下代码启动系统 python3 full_node.py --port=8001 --node=127.0.0.1:8000 --mine=1,但是每当我输入此代码时,每次打开和关闭终端时钱包地址都会更改。除了代码之外,我还添加了一个名为 wall 的地方。代码是这样的。

import argparse
    parser = argparse.ArgumentParser(description='Blockchain full node.')
    parser.add_argument('--node', type=str, help='Address of node to connect. If not will init fist node.')
    parser.add_argument('--port', required=True, type=int, help='Port on which run the node.')
    parser.add_argument('--mine', required=False, type=bool, help='Port on which run the node.')
    parser.add_argument('--diff', required=False, type=int, help='Difficulty')
    parser.add_argument('--wall', required=False, type=str, help='wallet address')

    args = parser.parse_args()
    _DB = DB()
    _DB.config['difficulty']
    _W = Wallet.create()
    _BC = Blockchain(_DB, _W)
    _API = API(_BC)
    logger.info(' ####### Server Address: %s ########' %_W.address)

    app.config['db'] = _DB
    app.config['wallet'] = args.wall
    app.config['bc'] = _BC
    app.config['api'] = _API
    app.config['port'] = args.port
    app.config['host'] = '127.0.0.1'
    app.config['nodes'] = set([args.node]) if args.node else set(['127.0.0.1:%s' % args.port])
    app.config['sync_running'] = False
    app.config['mine'] = args.mine

在我更改代码之前是这样的

import argparse
    parser = argparse.ArgumentParser(description='Blockchain full node.')
    parser.add_argument('--node', type=str, help='Address of node to connect. If not will init fist node.')
    parser.add_argument('--port', required=True, type=int, help='Port on which run the node.')
    parser.add_argument('--mine', required=False, type=bool, help='Port on which run the node.')
    parser.add_argument('--diff', required=False, type=int, help='Difficulty')

    args = parser.parse_args()
    _DB = DB()
    _DB.config['difficulty']
    _W = Wallet.create()
    _BC = Blockchain(_DB, _W)
    _API = API(_BC)
    logger.info(' ####### Sunucu Adresi: %s ########' %_W.address)

    app.config['db'] = _DB
    app.config['wallet'] = _W
    app.config['bc'] = _BC
    app.config['api'] = _API
    app.config['port'] = args.port  
    app.config['host'] = '127.0.0.1'
    app.config['nodes'] = set([args.node]) if args.node else set(['127.0.0.1:%s' % args.port])
    app.config['sync_running'] = False
    app.config['mine'] = args.mine

我希望能够在我想要的代码中放置一个钱包地址。每次启动终端时都只使用 1 个钱包。错误出现在上面的代码中或此处。

@classmethod
    def create(cls):
        inst = cls(b'',b'')
        _pub, _priv = rsa.newkeys(512)
        inst._pub = Address(_pub)
        inst._priv = _priv
        return inst

感谢所有提前帮助的人。

标签: pythonsyntaxtokenblockchain

解决方案


推荐阅读