mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
Update TxStatusRequest
This commit is contained in:
parent
de7afa79f5
commit
baecd7d377
3 changed files with 17 additions and 1 deletions
|
|
@ -57,6 +57,16 @@ func WriteTxLookupEntries(db DatabaseWriter, block *types.Block) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WriteTxLookupEntry(db DatabaseWriter, entry *TxLookupEntry, txHash common.Hash) {
|
||||||
|
data, err := rlp.EncodeToBytes(entry)
|
||||||
|
if err != nil {
|
||||||
|
log.Crit("Failed to encode transaction lookup entry", "err", err)
|
||||||
|
}
|
||||||
|
if err := db.Put(txLookupKey(txHash), data); err != nil {
|
||||||
|
log.Crit("Failed to store transaction lookup entry", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteTxLookupEntry removes all transaction data associated with a hash.
|
// DeleteTxLookupEntry removes all transaction data associated with a hash.
|
||||||
func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash) {
|
func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash) {
|
||||||
db.Delete(txLookupKey(hash))
|
db.Delete(txLookupKey(hash))
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"context"
|
"context"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ func LesRequest(req light.OdrRequest) LesOdrRequest {
|
||||||
return (*ChtRequest)(r)
|
return (*ChtRequest)(r)
|
||||||
case *light.BloomRequest:
|
case *light.BloomRequest:
|
||||||
return (*BloomRequest)(r)
|
return (*BloomRequest)(r)
|
||||||
|
case *light.TxStatusRequest:
|
||||||
|
return (*TxStatusRequest)(r)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -575,7 +577,10 @@ func (r *TxStatusRequest) GetCost(peer *peer) uint64 {
|
||||||
|
|
||||||
// CanSend tells if a certain peer is suitable for serving the given request
|
// CanSend tells if a certain peer is suitable for serving the given request
|
||||||
func (r *TxStatusRequest) CanSend(peer *peer) bool {
|
func (r *TxStatusRequest) CanSend(peer *peer) bool {
|
||||||
if peer.version == lpv1 {
|
peer.lock.RLock()
|
||||||
|
defer peer.lock.RUnlock()
|
||||||
|
|
||||||
|
if peer.version < lpv2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue