Skip to content

Commit 3d37aae

Browse files
multi: use bytea for hashes not text (#2020)
* use bytea for hashes not text also remove pkscript from db * go mod tidy Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com> --------- Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com> Co-authored-by: Jonathan Chappelow <chappjc@protonmail.com>
1 parent a09dfc6 commit 3d37aae

68 files changed

Lines changed: 2154 additions & 2443 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
run:
2-
deadline: 10m
2+
timeout: 10m
33

44
output:
55
format: github-actions,colored-line-number

api/types/insightapitypes.go

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package types
66

77
import (
8+
"encoding/hex"
89
"encoding/json"
910

1011
"github.com/decred/dcrdata/v8/db/dbtypes"
@@ -80,19 +81,38 @@ type InsightPagination struct {
8081
IsToday string `json:"isToday,omitempty"`
8182
}
8283

84+
var _ json.Unmarshaler = (*HexBytes)(nil)
85+
var _ json.Marshaler = HexBytes{}
86+
87+
type HexBytes []byte
88+
89+
func (hb HexBytes) MarshalJSON() ([]byte, error) {
90+
return []byte(`"` + hex.EncodeToString(hb) + `"`), nil // json.Marshal(hex.EncodeToString(hb)) but not absurdly inefficient
91+
}
92+
93+
func (hb *HexBytes) UnmarshalJSON(b []byte) error {
94+
var str string
95+
err := json.Unmarshal(b, &str)
96+
if err != nil {
97+
return err
98+
}
99+
*hb, err = hex.DecodeString(str)
100+
return err
101+
}
102+
83103
// AddressTxnOutput models an address transaction outputs.
84104
type AddressTxnOutput struct {
85-
Address string `json:"address"`
86-
TxnID string `json:"txid"`
87-
Vout uint32 `json:"vout"`
88-
BlockTime int64 `json:"ts,omitempty"`
89-
ScriptPubKey string `json:"scriptPubKey"`
90-
Height int64 `json:"height,omitempty"`
91-
BlockHash string `json:"block_hash,omitempty"`
92-
Amount float64 `json:"amount,omitempty"`
93-
Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec
94-
Satoshis int64 `json:"satoshis,omitempty"`
95-
Confirmations int64 `json:"confirmations"`
105+
Address string `json:"address"`
106+
TxnID string `json:"txid"`
107+
Vout uint32 `json:"vout"`
108+
BlockTime int64 `json:"ts,omitempty"`
109+
ScriptPubKey HexBytes `json:"scriptPubKey"`
110+
Height int64 `json:"height,omitempty"`
111+
BlockHash string `json:"block_hash,omitempty"`
112+
Amount float64 `json:"amount,omitempty"`
113+
Atoms int64 `json:"atoms,omitempty"` // Not Required per Insight spec
114+
Satoshis int64 `json:"satoshis,omitempty"`
115+
Confirmations int64 `json:"confirmations"`
96116
}
97117

98118
// TxOutFromDB converts a dbtypes.AddressTxnOutput to a api/types.AddressTxnOutput.

api/types/insightapitypes_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package types
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
func TestHexBytes_UnmarshalJSON(t *testing.T) {
9+
in := []byte(`"deadbeef"`)
10+
var hb HexBytes
11+
err := hb.UnmarshalJSON(in)
12+
if err != nil {
13+
t.Fatal(err)
14+
}
15+
fmt.Printf("%x\n", []byte(hb))
16+
out, _ := hb.MarshalJSON()
17+
fmt.Println(string(out))
18+
}

cmd/dcrdata/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/decred/dcrdata/cmd/dcrdata
22

3-
go 1.18
3+
go 1.21
44

55
replace (
66
github.com/decred/dcrdata/db/dcrpg/v8 => ../../db/dcrpg/
@@ -147,7 +147,7 @@ require (
147147
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
148148
github.com/kr/pretty v0.3.1 // indirect
149149
github.com/kr/text v0.2.0 // indirect
150-
github.com/lib/pq v1.10.4 // indirect
150+
github.com/lib/pq v1.10.9 // indirect
151151
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
152152
github.com/lightninglabs/neutrino v0.14.3-0.20221024182812-792af8548c14 // indirect
153153
github.com/lightningnetwork/lnd/clock v1.0.1 // indirect

cmd/dcrdata/go.sum

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA
278278
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
279279
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
280280
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
281+
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
281282
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
282283
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
283284
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -578,6 +579,7 @@ github.com/didip/tollbooth/v6 v6.1.3-0.20220606152938-a7634c70944a h1:YKCmFFZGFW
578579
github.com/didip/tollbooth/v6 v6.1.3-0.20220606152938-a7634c70944a/go.mod h1:wop/gy+XfJK/TXFmmVbFT46jsYOMU15K0Q1lWr4gIW8=
579580
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
580581
github.com/docker/docker v1.6.2 h1:HlFGsy+9/xrgMmhmN+NGhCc5SHGJ7I+kHosRR1xc/aI=
582+
github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
581583
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
582584
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
583585
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
@@ -690,6 +692,7 @@ github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1
690692
github.com/go-critic/go-critic v0.5.6/go.mod h1:cVjj0DfqewQVIlIAGexPCaGaZDAqGE29PYDDADIVNEo=
691693
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
692694
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
695+
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
693696
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
694697
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
695698
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
@@ -725,6 +728,7 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me
725728
github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw=
726729
github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4=
727730
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
731+
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
728732
github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4=
729733
github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ=
730734
github.com/go-toolsmith/astequal v0.0.0-20180903214952-dcb477bfacd6/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY=
@@ -767,6 +771,7 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw
767771
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
768772
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
769773
github.com/golang/glog v1.2.0 h1:uCdmnmatrKCgMBlM4rMuJZWOkPDqdbZPnrMXDY4gI68=
774+
github.com/golang/glog v1.2.0/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
770775
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
771776
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
772777
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
@@ -848,6 +853,7 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
848853
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
849854
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
850855
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
856+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
851857
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
852858
github.com/google/go-licenses v0.0.0-20210329231322-ce1d9163b77d/go.mod h1:+TYOmkVoJOpwnS0wfdsJCV9CoD5nJYsHoFk/0CrTK4M=
853859
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
@@ -1132,8 +1138,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
11321138
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
11331139
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
11341140
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
1135-
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
1136-
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
1141+
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
1142+
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
11371143
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
11381144
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
11391145
github.com/lightninglabs/neutrino v0.14.2/go.mod h1:OICUeTCn+4Tu27YRJIpWvvqySxx4oH4vgdP33Sw9RDc=
@@ -1535,6 +1541,7 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
15351541
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15361542
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
15371543
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
1544+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
15381545
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
15391546
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
15401547
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM=
@@ -2225,6 +2232,7 @@ google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCID
22252232
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
22262233
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
22272234
google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM=
2235+
google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds=
22282236
google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
22292237
google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
22302238
google.golang.org/genproto v0.0.0-20180808183934-383e8b2c3b9e/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
@@ -2407,6 +2415,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
24072415
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
24082416
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
24092417
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
2418+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
24102419
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
24112420
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
24122421
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
@@ -2447,7 +2456,9 @@ gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C
24472456
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
24482457
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
24492458
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2459+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
24502460
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
2461+
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
24512462
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
24522463
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
24532464
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

cmd/dcrdata/internal/api/apiroutes.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type DataSource interface {
5454
GetBlockHash(idx int64) (string, error)
5555
GetBlockHeight(hash string) (int64, error)
5656
GetBlockByHash(string) (*wire.MsgBlock, error)
57-
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, int8, error)
57+
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, error)
5858
SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)
5959
AddressHistory(address string, N, offset int64, txnType dbtypes.AddrTxnViewType) ([]*dbtypes.AddressRow, *dbtypes.AddressBalance, error)
6060
FillAddressTransactions(addrInfo *dbtypes.AddressInfo) error
@@ -80,7 +80,7 @@ type DataSource interface {
8080
GetStakeInfoExtendedByHash(hash string) *apitypes.StakeInfoExtended
8181
GetStakeInfoExtendedByHeight(idx int) *apitypes.StakeInfoExtended
8282
GetPoolInfo(idx int) *apitypes.TicketPoolInfo
83-
GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
83+
// GetPoolInfoByHash(hash string) *apitypes.TicketPoolInfo
8484
GetPoolInfoRange(idx0, idx1 int) []apitypes.TicketPoolInfo
8585
GetPoolValAndSizeRange(idx0, idx1 int) ([]float64, []uint32)
8686
GetPool(idx int64) ([]string, error)
@@ -1667,6 +1667,11 @@ func (c *appContext) addressIoCsv(crlf bool, w http.ResponseWriter, r *http.Requ
16671667
strDirection = "-1"
16681668
}
16691669

1670+
var matchingTx string
1671+
if r.MatchingTxHash != nil {
1672+
matchingTx = r.MatchingTxHash.String()
1673+
}
1674+
16701675
err = writer.Write([]string{
16711676
r.TxHash.String(),
16721677
strDirection,
@@ -1675,7 +1680,7 @@ func (c *appContext) addressIoCsv(crlf bool, w http.ResponseWriter, r *http.Requ
16751680
strconv.FormatFloat(dcrutil.Amount(r.Value).ToCoin(), 'f', -1, 64),
16761681
strconv.FormatInt(r.TxBlockTime, 10),
16771682
txhelpers.TxTypeToString(int(r.TxType)),
1678-
r.MatchingTxHash.String(),
1683+
matchingTx,
16791684
})
16801685
if err != nil {
16811686
return // too late to write an error code

cmd/dcrdata/internal/api/insight/apiroutes.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333

3434
type BlockDataSource interface {
3535
AddressBalance(address string) (bal *dbtypes.AddressBalance, cacheUpdated bool, err error)
36-
AddressIDsByOutpoint(txHash string, voutIndex uint32) ([]uint64, []string, int64, error)
36+
OutpointAddresses(txHash string, voutIndex uint32) ([]string, int64, error)
3737
AddressUTXO(address string) ([]*dbtypes.AddressTxnOutput, bool, error)
3838
BlockSummaryTimeRange(min, max int64, limit int) ([]dbtypes.BlockDataBasic, error)
3939
GetBlockHash(idx int64) (string, error)
@@ -130,7 +130,7 @@ func writeJSON(w http.ResponseWriter, thing interface{}, indent string) {
130130
func writeInsightError(w http.ResponseWriter, str string) {
131131
w.Header().Set("Content-Type", "text/html; charset=utf-8")
132132
w.WriteHeader(http.StatusBadRequest)
133-
io.WriteString(w, str)
133+
io.WriteString(w, str) //nolint:errcheck
134134
}
135135

136136
// Insight API response for an item NOT FOUND. This means the request was valid
@@ -140,7 +140,7 @@ func writeInsightError(w http.ResponseWriter, str string) {
140140
func writeInsightNotFound(w http.ResponseWriter, str string) {
141141
w.Header().Set("Content-Type", "text/html; charset=utf-8")
142142
w.WriteHeader(http.StatusNotFound)
143-
io.WriteString(w, str)
143+
io.WriteString(w, str) //nolint:errcheck
144144
}
145145

146146
func (iapi *InsightApi) getTransaction(w http.ResponseWriter, r *http.Request) {
@@ -459,7 +459,7 @@ func (iapi *InsightApi) getAddressesTxnOutput(w http.ResponseWriter, r *http.Req
459459
// need to do one more search on utxo and do not add if this is
460460
// already in the list as a confirmed tx.
461461
for _, utxo := range confirmedTxnOutputs {
462-
if utxo.Vout == f.Index && utxo.TxHash == f.Hash {
462+
if utxo.Vout == f.Index && utxo.TxHash == dbtypes.ChainHash(f.Hash) {
463463
continue FUNDING_TX_DUPLICATE_CHECK
464464
}
465465
}
@@ -473,7 +473,7 @@ func (iapi *InsightApi) getAddressesTxnOutput(w http.ResponseWriter, r *http.Req
473473
TxnID: fundingTx.Hash().String(),
474474
Vout: f.Index,
475475
BlockTime: fundingTx.MemPoolTime,
476-
ScriptPubKey: hex.EncodeToString(txOut.PkScript),
476+
ScriptPubKey: txOut.PkScript,
477477
Amount: dcrutil.Amount(txOut.Value).ToCoin(),
478478
Satoshis: txOut.Value,
479479
Confirmations: 0,

cmd/dcrdata/internal/api/insight/converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (iapi *InsightApi) DcrToInsightTxns(txs []*chainjson.TxRawResult, noAsm, no
7979
// work if the funding transaction is confirmed. Otherwise use RPC
8080
// to get the funding transaction outpoint addresses.
8181
if !vinGenerated {
82-
_, addresses, _, err := iapi.BlockData.AddressIDsByOutpoint(vin.Txid, vin.Vout)
82+
addresses, _, err := iapi.BlockData.OutpointAddresses(vin.Txid, vin.Vout)
8383
if err == nil && len(addresses) > 0 {
8484
InsightVin.Addr = addresses[0]
8585
} else {

cmd/dcrdata/internal/api/insight/socket.io.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ func NewSocketServer(params *chaincfg.Params, txGetter txhelpers.RawTransactionG
207207

208208
apiLog.Infof("Started Insight socket.io server.")
209209

210-
go server.Serve()
210+
go func() {
211+
apiLog.Warnf("SocketServer.Serve: %v", server.Serve())
212+
}()
211213
return server, nil
212214
}
213215

cmd/dcrdata/internal/explorer/explorer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ type explorerDataSource interface {
7070
Height() int64
7171
HeightDB() (int64, error)
7272
BlockHash(height int64) (string, error)
73-
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, int8, error)
73+
SpendingTransaction(fundingTx string, vout uint32) (string, uint32, error)
7474
SpendingTransactions(fundingTxID string) ([]string, []uint32, []uint32, error)
7575
PoolStatusForTicket(txid string) (dbtypes.TicketSpendType, dbtypes.TicketPoolStatus, error)
7676
TreasuryBalance() (*dbtypes.TreasuryBalance, error)
@@ -89,7 +89,7 @@ type explorerDataSource interface {
8989
TicketPoolVisualization(interval dbtypes.TimeBasedGrouping) (*dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, *dbtypes.PoolTicketsData, int64, error)
9090
TransactionBlocks(hash string) ([]*dbtypes.BlockStatus, []uint32, error)
9191
Transaction(txHash string) ([]*dbtypes.Tx, error)
92-
VinsForTx(*dbtypes.Tx) (vins []dbtypes.VinTxProperty, prevPkScripts []string, scriptVersions []uint16, err error)
92+
VinsForTx(*dbtypes.Tx) (vins []dbtypes.VinTxProperty, err error)
9393
VoutsForTx(*dbtypes.Tx) ([]dbtypes.Vout, error)
9494
PosIntervals(limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)
9595
TimeBasedIntervals(timeGrouping dbtypes.TimeBasedGrouping, limit, offset uint64) ([]*dbtypes.BlocksGroupedInfo, error)

0 commit comments

Comments
 (0)