decred / tinydecred

Python tools for Decred
ISC License
27 stars 14 forks source link

rpc: accept and return ByteArray rather than strings #61

Closed JoeGruffins closed 4 years ago

JoeGruffins commented 4 years ago

For all block hashes, block hex, filters, and txid use ByteArrays instead of strings.

@buck54321 ~I didn't touch any of the class/types yet, should I?~ Is what I've done so far look like what you had in mind?

buck54321 commented 4 years ago

Yeah. This is the right idea. What do you think about converting arguments based on type?

func convertHash(h):
  if isinstance(h, str):
    h = reversed(ByteArray(h))
  return h

func getSomeTxInfo(txhi):
  """
  Args:
    txhi (ByteArray or str): The transaction hash, or its hexadecimal representation (the transaction ID).
  """
  txHash = convertHash(txhi)
  return doStuff(txHash)

User can then pass either one.

JoeGruffins commented 4 years ago

ah, I remember you saying something about that before, sorry, I completely forgot. Will make it a choice then for rpc call arguments. Anything can also be str.

JoeGruffins commented 4 years ago

isort and black differed in opinion on a long import.

JoeGruffins commented 4 years ago

Will pop off the last commit and leave it to @teknico