-
Notifications
You must be signed in to change notification settings - Fork 128
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
Explorer V2 #202
Explorer V2 #202
Conversation
This is ready for review and merge. The only issue is the upstream vote vin issue, all unchecked items will be added in a later pr. |
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.
Not tested, but this really cleans things up. Will test.
dcrsqlite/apisource.go
Outdated
|
||
getTotalSpent := func(txs []*explorer.TxBasic) (total float64) { | ||
for _, tx := range txs { | ||
total += tx.Fee.ToCoin() |
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.
"spent" is the sum of the input values. What's going on here with tx.Fee?
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 assumed total sent is the sum of the input values and total spent is the sum of the fees
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.
The miner fees for a transaction are sum(inputs) - sum(outputs). Perhaps it's confusing, but I refer to the sum of inputs as spent since it's how much you as the sender spend to make the tx happen, while sent is how much you are sending to the output address(es). The difference is the fees that the miner gets.
The fees for a block could be just that sum total += tx.Fee.ToCoin()
over all transactions tx
. Or it could be done the way you started it by computing sum of sum of inputs, but then it would need sum of sum of outputs for the difference to get mining fee.
Double check against the Insight explorer to be sure it makes sense.
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.
Changed MiningFee calculation to sum fees in over all tx
except votes. I checked and the tx fees are the same on the Insight explorer.
dcrsqlite/apisource.go
Outdated
|
||
block.TotalSent = getTotalSent(block.Tx) + getTotalSent(block.Revs) + getTotalSent(block.Tickets) | ||
block.TotalSpent = getTotalSpent(block.Tx) + getTotalSpent(block.Revs) + getTotalSpent(block.Tickets) | ||
block.MiningFee = block.TotalSent - block.TotalSpent |
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.
for a valid tx, spent >= sent
(inputs - outputs = fee)
log.Errorf("GetRawTransactionVerbose failed for: %v", txhash) | ||
return nil | ||
} | ||
msgTx := txhelpers.MsgTxFromHex(txraw.Hex) |
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.
check for nil
dcrsqlite/apisource.go
Outdated
|
||
inputs := make([]explorer.Vin, 0, len(txraw.Vin)) | ||
for i, vin := range txraw.Vin { | ||
coinbase := vin.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.
please make a TODO that when Stakebase becomes a usable vin, we need to handle that too.
I'm OK with reusing explorer.Vin.CoinBase for both stakebase and coinbase, but we need to get the right one from vin depending on the type of tx
explorer/explorertypes.go
Outdated
type Vin struct { | ||
TxID string | ||
CoinBase string | ||
Address string |
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.
Assuming this is the previous outpoint's address(es)?
A vout, and thus this vin's prevout, may have multiple addresses decoded from their pkScript.
explorer/explorer.go
Outdated
@@ -1,4 +1,7 @@ | |||
package main | |||
// Package explorer handles the explorer subsystem for displaying the explorer pages | |||
// Copyright (c) 2017, The Dcrdata developers |
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.
👍 Let's update the LICENSE file too.
Although, I'm leaning toward all lowercase as our universal formatting, despite being a proper noun:
The dcrdata.org developers
or The dcrdata developers
r.Route("/{blockhash}", func(rd chi.Router) { | ||
rd.Use(exp.app.BlockHashPathOrIndexCtx) | ||
rd.Use(exp.blockHashPathOrIndexCtx) |
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.
It looked like the blockPage is only using getBlockHashCtx
now, so can't this middleware be a simpler handler that does not try to get the height when it's not needed? Or or is this route intended to handle height's input here instead of a hash?
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.
It handles both hash and height so http://localhost:7777/explorer/block/174288 and http://localhost:7777/explorer/block/000000000000000d1653f66e60c269e7fcbace5841005624ae47d680561d1b14 link to the same page
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.
OIC.
@@ -0,0 +1,124 @@ | |||
package explorer |
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.
Prepend license notification stuff
explorer/explorermiddleware.go
Outdated
|
||
func (exp *explorerUI) blockHashPathOrIndexCtx(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
// hash := chi.URLParam(r, "blockhash") |
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.
you can nuke all these comments
views/tx.tmpl
Outdated
<th class="text-center">DCR</th> | ||
<thead> | ||
<th>Address</th> | ||
<th class="text-center">Type</th> |
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.
minor formatting inconsistency
Needs rebase. |
8ef4b9f
to
2fe6cbd
Compare
dcrsqlite/apisource.go
Outdated
func makeExplorerTxBasic(data dcrjson.TxRawResult, msgTx *wire.MsgTx) *explorer.TxBasic { | ||
tx := new(explorer.TxBasic) | ||
tx.TxID = data.Txid | ||
tx.FormattedSize = humanize.Bytes(uint64(len(data.Hex))) |
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.
size is double. need data.Hex/2
Cool. I'm also seeing an vote version column header but no vote version. Perhaps because it just needs a rebase still. |
Not a rebase, a rework. The vote version stuff was dependent on the explorer V1 system. If @McEdward could take a look and add it in, that'll be great. |
Well that's unfortunate. Should not really be your problem that we just put the voteinfo PR in first. Sorry about that. @McEdward please provide guidance or better yet a commit on top of this branch that @RogueElement can cherry pick |
aaaand I just made this infinitely harder on you. sorry. The restyling just went in. With a decent 3-way merge tool this shouldn't be horrible though. |
@gozart1 Some pretty hefty conflicts landed here following your redesign PR, which was inevitable, but if there are any non-trivial or non-obvious edits that seem to conflict with dabira's, he could probably use a hand sorting it out. Thanks and sorry for the complications. Several PRs had to go in at almost the same time. |
I can take a look at this in about 12hrs from now. The deltas a huge because the layout change a lot. But the actual content that #202 modifies is not that large. So I suggest the following strategy: Copy and paste these templates
directly from master, then by looking over your existing 13 commits, manually re-apply the changes you made to the tmpl files in this PR to them. One way to easily see all the changes would be to diff this branch with the commit in master before my PR was merged. You may want to create a 2nd branch to be extra safe and just keep this one around for reference. Once you've copied the templates and applied the changes the diff should be clean and we can double check to make sure all your changes made it in. |
Fixed explore and block pages Added tx page Added Address page Fixed Tx and Address pages Fixed minor errors and started ro remove explorer v1 Removed unnecessary conversion Removed redundant function Change IsStakeBase check for now Added non-redundant function Updated LICENSE and added minor changes
03667f5
to
2835f87
Compare
Squashed and rebased, just needs a review and merge |
dcrsqlite/apisource.go
Outdated
return nil | ||
} | ||
msgTx := txhelpers.MsgTxFromHex(txraw.Hex) | ||
if err != nil { |
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.
oops, you're checking err
here instead of msgTx
<a href="/explorer/address/{{.}}">{{.}}</a> | ||
<td> | ||
{{range .Addresses}} | ||
<a class="break-word mono" href="/explorer/address/{{.}}">{{.}}</a><br> |
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.
Just want to make sure losing the class="break-word mono"
part was intentional since the rebase was pretty epic. a break-word
also disappeared way above too so I'm guessing this wasn't a mistake, but I want to be sure.
* Started on Explorer Version 2 Fixed explore and block pages Added tx page Added Address page Fixed Tx and Address pages Fixed minor errors and started ro remove explorer v1 Removed unnecessary conversion Removed redundant function Change IsStakeBase check for now Added non-redundant function Updated LICENSE and added minor changes * Fixed MiningFee calculation and removed unused function * Corrected msgTx error check
* Started on Explorer Version 2 Fixed explore and block pages Added tx page Added Address page Fixed Tx and Address pages Fixed minor errors and started ro remove explorer v1 Removed unnecessary conversion Removed redundant function Change IsStakeBase check for now Added non-redundant function Updated LICENSE and added minor changes * Fixed MiningFee calculation and removed unused function * Corrected msgTx error check
Explorer V2
For issue #198 and #138
Current issues being addressed in V2:
Improvements over V1: