-
Notifications
You must be signed in to change notification settings - Fork 1
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
api/insight: use actual net params #1
api/insight: use actual net params #1
Conversation
lots of style changes
if txHex == "" { | ||
writeInsightNotFound(w, fmt.Sprintf("Unable to get transaction (%s)", txHex)) | ||
return | ||
} | ||
|
||
hexOutput := new(apitypes.InsightRawTx) | ||
hexOutput.Rawtx = txHex | ||
hexOutput := &apitypes.InsightRawTx{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct literal init is preferred, at least for consistency
for _, tx := range txs { | ||
|
||
vInSum := float64(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var vInSum float64
inits the variable to the zero value for the data type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, i'm still unclear when you want me to use := vs var inits. we are getting there :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well same here, we're not super strict, but we try to be internally consistent.
A couple resources for idiomatic go:
https://golang.org/doc/effective_go.html?
https://dmitri.shuralyov.com/idiomatic-go
BTW, this was one of my favorite pages when I was first learning go:
http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/
@@ -112,7 +110,7 @@ func (c *insightApiContext) TxConverterWithParams(txs []*dcrjson.TxRawResult, no | |||
txNew.Fees = dcramt.ToCoin() | |||
|
|||
// Return true if coinbase value is not empty, return 0 at some fields | |||
if txNew.Vins != nil && len(txNew.Vins[0].CoinBase) > 0 { | |||
if txNew.Vins != nil && txNew.Vins[0].CoinBase != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either way is valid, but for strings, the semantics are clear from the syntax on the right without even knowing the type of CoinBase
@@ -150,19 +148,17 @@ func (c *insightApiContext) TxConverterWithParams(txs []*dcrjson.TxRawResult, no | |||
return newTxs, nil | |||
} | |||
|
|||
// BlockConverter converts dcrd-block to Insight block | |||
func (c *insightApiContext) BlockConverter(inBlocks []*dcrjson.GetBlockVerboseResult) ([]*apitypes.InsightBlockResult, error) { | |||
params := &chaincfg.MainNetParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this was a bug. I was about to remove the receiver ((c *insightApiContext)
) from the function signature since c
wasn't used, but I was the actual chaincfg params were needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right.
* dcrsqlite: add test to reproduce the issue decred#515 decred#515 * dcrsqlite: create DB-file parent directory when necessary Fixes decred#515 * dcrsqlite: move test helpers to a testutil package * testutil functions take *testing.T (#1)
lots of style changes