Skip to content

Commit

Permalink
Add another trace region once a DB tx has been opened.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Oct 11, 2019
1 parent 0b1ac44 commit fe6e4c8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@ func (s *Server) listScripts(ctx context.Context, icmd interface{}) (interface{}
return nil, errUnloadedWallet
}

redeemScripts, err := w.FetchAllRedeemScripts(ctx, )
redeemScripts, err := w.FetchAllRedeemScripts(ctx)
if err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (s *walletServer) AccountNumber(ctx context.Context, req *pb.AccountNumberR
}

func (s *walletServer) Accounts(ctx context.Context, req *pb.AccountsRequest) (*pb.AccountsResponse, error) {
resp, err := s.wallet.Accounts(ctx, )
resp, err := s.wallet.Accounts(ctx)
if err != nil {
return nil, translateError(err)
}
Expand Down Expand Up @@ -645,11 +645,11 @@ func (s *walletServer) Balance(ctx context.Context, req *pb.BalanceRequest) (
}

func (s *walletServer) TicketPrice(ctx context.Context, req *pb.TicketPriceRequest) (*pb.TicketPriceResponse, error) {
sdiff, err := s.wallet.NextStakeDifficulty(ctx, )
sdiff, err := s.wallet.NextStakeDifficulty(ctx)
if err != nil {
return nil, translateError(err)
}
_, tipHeight := s.wallet.MainChainTip(ctx, )
_, tipHeight := s.wallet.MainChainTip(ctx)
resp := &pb.TicketPriceResponse{
TicketPrice: int64(sdiff),
Height: tipHeight,
Expand All @@ -668,7 +668,7 @@ func (s *walletServer) StakeInfo(ctx context.Context, req *pb.StakeInfoRequest)
if rpc != nil {
si, err = s.wallet.StakeInfoPrecise(ctx, rpc)
} else {
si, err = s.wallet.StakeInfo(ctx, )
si, err = s.wallet.StakeInfo(ctx)
}
if err != nil {
return nil, translateError(err)
Expand Down Expand Up @@ -2752,7 +2752,7 @@ func (s *votingServer) checkReady() bool {

func (s *votingServer) VoteChoices(ctx context.Context, req *pb.VoteChoicesRequest) (*pb.VoteChoicesResponse, error) {
version, agendas := wallet.CurrentAgendas(s.wallet.ChainParams())
choices, voteBits, err := s.wallet.AgendaChoices(ctx, )
choices, voteBits, err := s.wallet.AgendaChoices(ctx)
if err != nil {
return nil, translateError(err)
}
Expand Down Expand Up @@ -2957,7 +2957,7 @@ func (s *decodeMessageServer) DecodeRawTransaction(ctx context.Context, req *pb.
}

func (s *walletServer) BestBlock(ctx context.Context, req *pb.BestBlockRequest) (*pb.BestBlockResponse, error) {
hash, height := s.wallet.MainChainTip(ctx, )
hash, height := s.wallet.MainChainTip(ctx)
resp := &pb.BestBlockResponse{
Hash: hash[:],
Height: uint32(height),
Expand Down
3 changes: 2 additions & 1 deletion wallet/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,12 @@ func (w *Wallet) persistReturnedChild(ctx context.Context, maybeDBTX walletdb.Re
// transaction as necessary.
if maybeDBTX == nil {
var err error
defer trace.StartRegion(ctx, "db.Update").End()
maybeDBTX, err = w.db.BeginReadWriteTx()
if err != nil {
return err
}
region := trace.StartRegion(ctx, "db.Update")
region := trace.StartRegion(ctx, "db.ReadWriteTx")
defer func() {
if rerr == nil {
rerr = maybeDBTX.Commit()
Expand Down
3 changes: 2 additions & 1 deletion wallet/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ func (w *Wallet) MakeSecp256k1MultiSigScript(ctx context.Context, secp256k1Addrs

if dbtx == nil {
var err error
defer trace.StartRegion(ctx, "db.View").End()
dbtx, err = w.db.BeginReadTx()
if err != nil {
return nil, err
}
defer trace.StartRegion(ctx, "db.View").End()
defer trace.StartRegion(ctx, "db.ReadTx").End()
addrmgrNs = dbtx.ReadBucket(waddrmgrNamespaceKey)
}
addrInfo, err := w.Manager.Address(addrmgrNs, addr)
Expand Down
8 changes: 6 additions & 2 deletions wallet/walletdb/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,14 @@ type DB interface {
// any occurred).
func View(ctx context.Context, db DB, f func(tx ReadTx) error) error {
defer trace.StartRegion(ctx, "db.View").End()

tx, err := db.BeginReadTx()
if err != nil {
return err
}

defer trace.StartRegion(ctx, "db.ReadTx").End()

// Rollback the transaction after f returns or panics. Do not recover from
// any panic to keep the original stack trace intact.
defer func() {
Expand All @@ -224,12 +226,14 @@ func View(ctx context.Context, db DB, f func(tx ReadTx) error) error {
// by f is still returned. If the commit fails, the commit error is returned.
func Update(ctx context.Context, db DB, f func(tx ReadWriteTx) error) (err error) {
defer trace.StartRegion(ctx, "db.Update").End()

tx, err := db.BeginReadWriteTx()
if err != nil {
return err
}

defer trace.StartRegion(ctx, "db.ReadWriteTx").End()

// Commit or rollback the transaction after f returns or panics. Do not
// recover from the panic to keep the original stack trace intact.
panicked := true
Expand Down

0 comments on commit fe6e4c8

Please sign in to comment.