Update TxStatusRequest

This commit is contained in:
CocoaHuke 2018-06-21 22:06:19 -07:00
parent de7afa79f5
commit baecd7d377
No known key found for this signature in database
GPG key ID: E300819C1AE33223
3 changed files with 17 additions and 1 deletions

View file

@ -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.
func DeleteTxLookupEntry(db DatabaseDeleter, hash common.Hash) {
db.Delete(txLookupKey(hash))

View file

@ -17,6 +17,7 @@
package eth
import (
"errors"
"context"
"math/big"

View file

@ -68,6 +68,8 @@ func LesRequest(req light.OdrRequest) LesOdrRequest {
return (*ChtRequest)(r)
case *light.BloomRequest:
return (*BloomRequest)(r)
case *light.TxStatusRequest:
return (*TxStatusRequest)(r)
default:
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
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 true