Lookup input transactions in mempool
This commit is contained in:
parent
2598dff10d
commit
7c71876c12
@ -274,8 +274,8 @@ func waitForSignalAndShutdown(s *server.HTTPServer, mq *bchain.MQ, timeout time.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func printResult(txid string) error {
|
func printResult(txid string, vout uint32, isOutput bool) error {
|
||||||
glog.Info(txid)
|
glog.Info(txid, vout, isOutput)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -85,7 +85,7 @@ func (d *RocksDB) Close() error {
|
|||||||
|
|
||||||
// GetTransactions finds all input/output transactions for address specified by outputScript.
|
// GetTransactions finds all input/output transactions for address specified by outputScript.
|
||||||
// Transaction are passed to callback function.
|
// Transaction are passed to callback function.
|
||||||
func (d *RocksDB) GetTransactions(outputScript []byte, lower uint32, higher uint32, fn func(txid string) error) (err error) {
|
func (d *RocksDB) GetTransactions(outputScript []byte, lower uint32, higher uint32, fn func(txid string, vout uint32, isOutput bool) error) (err error) {
|
||||||
if glog.V(1) {
|
if glog.V(1) {
|
||||||
glog.Infof("rocksdb: address get %s %d-%d ", unpackOutputScript(outputScript), lower, higher)
|
glog.Infof("rocksdb: address get %s %d-%d ", unpackOutputScript(outputScript), lower, higher)
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ func (d *RocksDB) GetTransactions(outputScript []byte, lower uint32, higher uint
|
|||||||
glog.Infof("rocksdb: output %s: %s", hex.EncodeToString(key), hex.EncodeToString(val))
|
glog.Infof("rocksdb: output %s: %s", hex.EncodeToString(key), hex.EncodeToString(val))
|
||||||
}
|
}
|
||||||
for _, o := range outpoints {
|
for _, o := range outpoints {
|
||||||
if err := fn(o.txid); err != nil {
|
if err := fn(o.txid, o.vout, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
boutpoint, err := packOutpoint(o.txid, o.vout)
|
boutpoint, err := packOutpoint(o.txid, o.vout)
|
||||||
@ -136,7 +136,7 @@ func (d *RocksDB) GetTransactions(outputScript []byte, lower uint32, higher uint
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, i := range inpoints {
|
for _, i := range inpoints {
|
||||||
if err := fn(i.txid); err != nil {
|
if err := fn(i.txid, i.vout, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -168,7 +168,7 @@ func (s *HTTPServer) confirmedTransactions(w http.ResponseWriter, r *http.Reques
|
|||||||
respondError(w, err, fmt.Sprint("confirmedTransactions for address", address))
|
respondError(w, err, fmt.Sprint("confirmedTransactions for address", address))
|
||||||
}
|
}
|
||||||
txList := transactionList{}
|
txList := transactionList{}
|
||||||
err = s.db.GetTransactions(script, lower, higher, func(txid string) error {
|
err = s.db.GetTransactions(script, lower, higher, func(txid string, vout uint32, isOutput bool) error {
|
||||||
txList.Txid = append(txList.Txid, txid)
|
txList.Txid = append(txList.Txid, txid)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -184,8 +184,14 @@ func (s *HTTPServer) transactions(w http.ResponseWriter, r *http.Request) {
|
|||||||
respondError(w, err, fmt.Sprint("transactions for address", address))
|
respondError(w, err, fmt.Sprint("transactions for address", address))
|
||||||
}
|
}
|
||||||
txList := transactionList{}
|
txList := transactionList{}
|
||||||
err = s.db.GetTransactions(script, lower, higher, func(txid string) error {
|
err = s.db.GetTransactions(script, lower, higher, func(txid string, vout uint32, isOutput bool) error {
|
||||||
txList.Txid = append(txList.Txid, txid)
|
txList.Txid = append(txList.Txid, txid)
|
||||||
|
if isOutput {
|
||||||
|
input := s.mempool.GetInput(txid, vout)
|
||||||
|
if input != "" {
|
||||||
|
txList.Txid = append(txList.Txid, txid)
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user