Skip to content

Including Magic in hash makes RpcClient unusable for multiple blockchains #1900

@devhawk

Description

@devhawk

RpcClient apps must configure ProtocolSettings with the correct magic value for tx/block hashes to match the between client and server. However, ProtocolSettings can only be specified once / process and can never be changed. So it's impossible to create multiple RpcClients that can send raw transactions to different blockchains.

Additionally, RpcClient won't be able to send raw transactions to any blockchain except the one with the hardcoded default unless the developer explicitly configures it - either with a protocol.json file or by calling ProtocolSettings.Initialize.

Ideally, RpcClient would accept a magic value in it's constructor so you could write something like this:

var mainNetRpcClient = new RpcClient("http://main.network"); // magic value defaults to MainNet value
var testNetRpcClient = new RpcClient("http://test.network", TEST_NET_MAGIC); magic value explicitly set

However, because of the way ProtocolSettings is managed + the intrinsic manner in Neo.Network.P2P.Helper.GetHashData retrieves the magic value, this type of initialization is impossible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions