Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show hash on sendrawtransaction #796

Merged
merged 9 commits into from Jun 4, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions neo/Network/RPC/RpcServer.cs
Expand Up @@ -90,12 +90,17 @@ private JObject GetInvokeResult(byte[] script)
return json;
}

private static JObject GetRelayResult(RelayResultReason reason)
private static JObject GetRelayResult(RelayResultReason reason, UInt256 hash)
{
switch (reason)
{
case RelayResultReason.Succeed:
return true;
{
var ret = new JObject();
ret["relayed"] = true;
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
ret["hash"] = hash.ToString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should call this txid instead of hash to stay consistent. e.g. sendtoaddress and sendfrom also use txid

Otherwise looks good

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird to return two different structures for blocks and transactions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can leave blocks as before, but looks weird too

Copy link
Member

@erikzhang erikzhang Jun 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should use hash uniformly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change the neo-plugin to "hash"

return ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't quickly tell but will this result in

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true,
  "hash": "some tx id hash"
}

or in

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
     "result": true,
     "hash": "some tx id hash"
   }
}

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second one, but i will change result for 'relayed'

}
case RelayResultReason.AlreadyExists:
throw new RpcException(-501, "Block or transaction already exists and cannot be sent repeatedly.");
case RelayResultReason.OutOfMemory:
Expand Down Expand Up @@ -606,13 +611,13 @@ private JObject ListPlugins()
private JObject SendRawTransaction(Transaction tx)
{
RelayResultReason reason = system.Blockchain.Ask<RelayResultReason>(tx).Result;
return GetRelayResult(reason);
return GetRelayResult(reason, tx.Hash);
}

private JObject SubmitBlock(Block block)
{
RelayResultReason reason = system.Blockchain.Ask<RelayResultReason>(block).Result;
return GetRelayResult(reason);
return GetRelayResult(reason, block.Hash);
}

private JObject ValidateAddress(string address)
Expand Down