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

api/insight: use actual net params #1

Merged
merged 1 commit into from
Jun 14, 2018

Conversation

chappjc
Copy link

@chappjc chappjc commented Jun 14, 2018

lots of style changes

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{
Copy link
Author

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)
Copy link
Author

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

Copy link
Owner

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 :)

Copy link
Author

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 != "" {
Copy link
Author

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
Copy link
Author

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.

Copy link
Owner

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.

@papacarp papacarp merged commit 4684756 into papacarp:insight_misc1to10 Jun 14, 2018
@chappjc chappjc deleted the insight_misc1to10 branch June 14, 2018 18:06
papacarp pushed a commit that referenced this pull request Jul 4, 2018
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants