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

main: Update for mempool/v2. #1616

Merged
merged 1 commit into from Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion blockmanager.go
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/decred/dcrd/chaincfg/chainhash"
"github.com/decred/dcrd/database"
"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrd/mempool"
"github.com/decred/dcrd/mempool/v2"
"github.com/decred/dcrd/wire"
)

Expand Down
2 changes: 1 addition & 1 deletion config.go
Expand Up @@ -27,7 +27,7 @@ import (
_ "github.com/decred/dcrd/database/ffldb"
"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrd/internal/version"
"github.com/decred/dcrd/mempool"
"github.com/decred/dcrd/mempool/v2"
"github.com/decred/dcrd/sampleconfig"
"github.com/decred/slog"
flags "github.com/jessevdk/go-flags"
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Expand Up @@ -13,13 +13,12 @@ require (
github.com/decred/dcrd/connmgr v1.0.2
github.com/decred/dcrd/database v1.0.3
github.com/decred/dcrd/dcrec/secp256k1 v1.0.1
github.com/decred/dcrd/dcrjson v1.2.0 // indirect
github.com/decred/dcrd/dcrjson/v2 v2.0.0
github.com/decred/dcrd/dcrutil v1.2.0
github.com/decred/dcrd/fees v1.0.0
github.com/decred/dcrd/gcs v1.0.2
github.com/decred/dcrd/hdkeychain v1.1.1
github.com/decred/dcrd/mempool v1.2.0
github.com/decred/dcrd/mempool/v2 v2.0.0
github.com/decred/dcrd/mining v1.1.0
github.com/decred/dcrd/peer v1.1.0
github.com/decred/dcrd/rpcclient/v2 v2.0.0
Expand Down Expand Up @@ -52,6 +51,7 @@ replace (
github.com/decred/dcrd/gcs => ./gcs
github.com/decred/dcrd/hdkeychain => ./hdkeychain
github.com/decred/dcrd/limits => ./limits
github.com/decred/dcrd/mempool/v2 => ./mempool
github.com/decred/dcrd/mining => ./mining
github.com/decred/dcrd/peer => ./peer
github.com/decred/dcrd/rpcclient/v2 => ./rpcclient
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Expand Up @@ -38,10 +38,6 @@ github.com/decred/dcrd/dcrec/edwards v0.0.0-20190130161649-59ed4247a1d5 h1:qA+q5
github.com/decred/dcrd/dcrec/edwards v0.0.0-20190130161649-59ed4247a1d5/go.mod h1:+ehP0Hk/mesyZXttxCtBbhPX23BMpZJ1pcVBqUfbmvU=
github.com/decred/dcrd/dcrec/secp256k1 v1.0.1 h1:EFWVd1p0t0Y5tnsm/dJujgV0ORogRJ6vo7CMAjLseAc=
github.com/decred/dcrd/dcrec/secp256k1 v1.0.1/go.mod h1:lhu4eZFSfTJWUnR3CFRcpD+Vta0KUAqnhTsTksHXgy0=
github.com/decred/dcrd/dcrjson v1.1.0 h1:pFpbay3cWACkgloFxWjHBwlXWG2+S2QCJJzNxL40hwg=
github.com/decred/dcrd/dcrjson v1.1.0/go.mod h1:ozddIaeF+EAvZZvFuB3zpfxhyxBGfvbt22crQh+PYuI=
github.com/decred/dcrd/dcrjson v1.2.0 h1:3BFFQHq3/YO/zae9WLxQkXsX6AXKx3+M8H3yk4oXZi0=
github.com/decred/dcrd/dcrjson v1.2.0/go.mod h1:ozddIaeF+EAvZZvFuB3zpfxhyxBGfvbt22crQh+PYuI=
github.com/decred/dcrd/dcrjson/v2 v2.0.0 h1:W0q4Alh36c5N318eUpfmU8kXoCNgImMLI87NIXni9Us=
github.com/decred/dcrd/dcrjson/v2 v2.0.0/go.mod h1:FYueNy8BREAFq04YNEwcTsmGFcNqY+ehUUO81w2igi4=
github.com/decred/dcrd/dcrutil v1.2.0 h1:Pd5Wf650g6Xu6luYDfGkh1yiUoPUAgqzRu6K+BGyJGg=
Expand All @@ -52,8 +48,8 @@ github.com/decred/dcrd/gcs v1.0.2 h1:wZjxeC9WPBoRApaAQpBrzvN9NA0iS2KWrTJa9IiDgc8
github.com/decred/dcrd/gcs v1.0.2/go.mod h1:eLCvrzUsWro48TlTyrmFcZAZqnllYFz0vEv5VZtufF4=
github.com/decred/dcrd/hdkeychain v1.1.1 h1:6+BwOmPfEyw/Krm+91RXysc76F1jqCta3m45DyD5+s4=
github.com/decred/dcrd/hdkeychain v1.1.1/go.mod h1:CLBVXLoO63fIiqkv38KR23zXGSgrfiAWOybOKTneLhA=
github.com/decred/dcrd/mempool v1.2.0 h1:jFlofZOz9QPv7eXWYYyQ9gBq6roeV2SaYI1uDD4wbF0=
github.com/decred/dcrd/mempool v1.2.0/go.mod h1:jbL4+jOVjTU/MfgYV8SptKVpOTFD+DeHC15DhdJsfAI=
github.com/decred/dcrd/mempool/v2 v2.0.0 h1:QoQC5Lri311unqCr/PejBEwNERWMSWtnSa7bpBFZjbQ=
github.com/decred/dcrd/mempool/v2 v2.0.0/go.mod h1:/AH0mFOKCglSdEDubF3oRDbWUmDj26gwnrIlFsr+lbM=
github.com/decred/dcrd/mining v1.1.0 h1:9Wtla+i+pEjfYsNCfixsipmyyoB26DgL4LSXWAin/zw=
github.com/decred/dcrd/mining v1.1.0/go.mod h1:NQEtX604XgNwKcPFId1hVTTiBqmVQDlnqV1yNqGl4oU=
github.com/decred/dcrd/peer v1.1.0 h1:Il05Vzt2uW6cOCISJgT3rTtJ0BEs/09bSvivGMmQt8g=
Expand Down
2 changes: 1 addition & 1 deletion log.go
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/decred/dcrd/connmgr"
"github.com/decred/dcrd/database"
"github.com/decred/dcrd/fees"
"github.com/decred/dcrd/mempool"
"github.com/decred/dcrd/mempool/v2"
"github.com/decred/dcrd/peer"
"github.com/decred/dcrd/txscript"
"github.com/decred/slog"
Expand Down
36 changes: 32 additions & 4 deletions rpcserver.go
Expand Up @@ -45,7 +45,7 @@ import (
"github.com/decred/dcrd/dcrjson/v2"
"github.com/decred/dcrd/dcrutil"
"github.com/decred/dcrd/internal/version"
"github.com/decred/dcrd/mempool"
"github.com/decred/dcrd/mempool/v2"
"github.com/decred/dcrd/txscript"
"github.com/decred/dcrd/wire"
"github.com/jrick/bitset"
Expand Down Expand Up @@ -3432,15 +3432,43 @@ func handleGetRawMempool(s *rpcServer, cmd interface{}, closeChan <-chan struct{
case dcrjson.GRMAll:
// Nothing to do
default:
return nil, rpcInvalidError("Invalid transaction "+
"type: %T", *c.TxType)
supported := []dcrjson.GetRawMempoolTxTypeCmd{dcrjson.GRMRegular,
dcrjson.GRMTickets, dcrjson.GRMVotes, dcrjson.GRMRevocations,
dcrjson.GRMAll}
return nil, rpcInvalidError("Invalid transaction type: %s -- "+
"supported types: %v", *c.TxType, supported)
}
}

// Return verbose results if requested.
mp := s.server.txMemPool
if c.Verbose != nil && *c.Verbose {
return mp.RawMempoolVerbose(filterType), nil
descs := mp.VerboseTxDescs()
result := make(map[string]*dcrjson.GetRawMempoolVerboseResult, len(descs))
for i := range descs {
desc := descs[i]
if filterType != nil && desc.Type != *filterType {
continue
}

tx := desc.Tx
mpd := &dcrjson.GetRawMempoolVerboseResult{
Size: int32(tx.MsgTx().SerializeSize()),
Fee: dcrutil.Amount(desc.Fee).ToCoin(),
Time: desc.Added.Unix(),
Height: desc.Height,
StartingPriority: desc.StartingPriority,
CurrentPriority: desc.CurrentPriority,
Depends: make([]string, len(desc.Depends)),
}
for j, depDesc := range desc.Depends {
mpd.Depends[j] = depDesc.Tx.Hash().String()
}

result[tx.Hash().String()] = mpd
}

return result, nil
}

// The response is simply an array of the transaction hashes if the
Expand Down
2 changes: 1 addition & 1 deletion server.go
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/decred/dcrd/gcs"
"github.com/decred/dcrd/gcs/blockcf"
"github.com/decred/dcrd/internal/version"
"github.com/decred/dcrd/mempool"
"github.com/decred/dcrd/mempool/v2"
"github.com/decred/dcrd/mining"
"github.com/decred/dcrd/peer"
"github.com/decred/dcrd/txscript"
Expand Down