mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-19 14:34:17 +00:00
expose /tx?hash="XXXXXXXXXXXX" RPC call
This commit is contained in:
+3
-1
@@ -1,6 +1,7 @@
|
||||
package state
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -251,7 +252,8 @@ func (s *State) ApplyBlock(eventCache types.Fireable, proxyAppConn proxy.AppConn
|
||||
for i, r := range txResults {
|
||||
if r != nil {
|
||||
tx := block.Txs[i]
|
||||
batch.Index(string(tx.Hash()), *r)
|
||||
// dd2e325f79f7e5f77788759d278c1d4b370c842e => {"height":2405, "index":0, ...}
|
||||
batch.Index(hex.EncodeToString(tx.Hash()), *r)
|
||||
}
|
||||
}
|
||||
s.TxIndexer.Batch(batch)
|
||||
|
||||
+1
-11
@@ -44,13 +44,12 @@ type State struct {
|
||||
TxIndexer tx.Indexer `json:"-"` // Transaction indexer.
|
||||
}
|
||||
|
||||
// Used in tests.
|
||||
func LoadState(db dbm.DB) *State {
|
||||
return loadState(db, stateKey)
|
||||
}
|
||||
|
||||
func loadState(db dbm.DB, key []byte) *State {
|
||||
s := &State{db: db}
|
||||
s := &State{db: db, TxIndexer: &txindexer.Null{}}
|
||||
buf := db.Get(key)
|
||||
if len(buf) == 0 {
|
||||
return nil
|
||||
@@ -132,15 +131,6 @@ func GetState(config cfg.Config, stateDB dbm.DB) *State {
|
||||
state.Save()
|
||||
}
|
||||
|
||||
// Transaction indexing
|
||||
switch config.GetString("tx_indexer") {
|
||||
case "kv":
|
||||
store := dbm.NewDB("tx_indexer", config.GetString("db_backend"), config.GetString("db_dir"))
|
||||
state.TxIndexer = txindexer.NewKV(store)
|
||||
default:
|
||||
state.TxIndexer = &txindexer.Null{}
|
||||
}
|
||||
|
||||
return state
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package indexer
|
||||
|
||||
import "github.com/tendermint/tendermint/types"
|
||||
import (
|
||||
"errors"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// Null acts as a /dev/null.
|
||||
type Null struct{}
|
||||
|
||||
// Tx panics.
|
||||
func (indexer *Null) Tx(hash string) (*types.TxResult, error) {
|
||||
panic("You are trying to get the transaction from a null indexer")
|
||||
return nil, errors.New("Indexing is disabled (set `tx_indexer=kv` in config)")
|
||||
}
|
||||
|
||||
// Batch returns nil.
|
||||
|
||||
Reference in New Issue
Block a user