mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
rawdb, eth, ethapi, les, light: Fix "file is not goimported"
This commit is contained in:
parent
c7ef06016a
commit
920731fe99
8 changed files with 29 additions and 29 deletions
|
|
@ -58,13 +58,13 @@ func WriteTxLookupEntries(db DatabaseWriter, block *types.Block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteTxLookupEntry(db DatabaseWriter, entry *TxLookupEntry, txHash common.Hash) {
|
func WriteTxLookupEntry(db DatabaseWriter, entry *TxLookupEntry, txHash common.Hash) {
|
||||||
data, err := rlp.EncodeToBytes(entry)
|
data, err := rlp.EncodeToBytes(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Crit("Failed to encode transaction lookup entry", "err", err)
|
log.Crit("Failed to encode transaction lookup entry", "err", err)
|
||||||
}
|
}
|
||||||
if err := db.Put(txLookupKey(txHash), data); err != nil {
|
if err := db.Put(txLookupKey(txHash), data); err != nil {
|
||||||
log.Crit("Failed to store transaction lookup entry", "err", err)
|
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.
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
package eth
|
package eth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts"
|
"github.com/ethereum/go-ethereum/accounts"
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ type Backend interface {
|
||||||
Stats() (pending int, queued int)
|
Stats() (pending int, queued int)
|
||||||
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
|
TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions)
|
||||||
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
|
SubscribeNewTxsEvent(chan<- core.NewTxsEvent) event.Subscription
|
||||||
TxStatusByHash(ctx context.Context, hash common.Hash) (core.TxStatus, error)
|
TxStatusByHash(ctx context.Context, hash common.Hash) (core.TxStatus, error)
|
||||||
|
|
||||||
ChainConfig() *params.ChainConfig
|
ChainConfig() *params.ChainConfig
|
||||||
CurrentBlock() *types.Block
|
CurrentBlock() *types.Block
|
||||||
|
|
|
||||||
|
|
@ -1109,7 +1109,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
||||||
|
|
||||||
p.fcServer.GotReply(resp.ReqID, resp.BV)
|
p.fcServer.GotReply(resp.ReqID, resp.BV)
|
||||||
|
|
||||||
deliverMsg = &Msg{
|
deliverMsg = &Msg{
|
||||||
MsgType: MsgTxStatus,
|
MsgType: MsgTxStatus,
|
||||||
ReqID: resp.ReqID,
|
ReqID: resp.ReqID,
|
||||||
Obj: resp.Status,
|
Obj: resp.Status,
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ const (
|
||||||
MsgProofsV2
|
MsgProofsV2
|
||||||
MsgHeaderProofs
|
MsgHeaderProofs
|
||||||
MsgHelperTrieProofs
|
MsgHelperTrieProofs
|
||||||
MsgTxStatus
|
MsgTxStatus
|
||||||
)
|
)
|
||||||
|
|
||||||
// Msg encodes a LES message that delivers reply data for a request
|
// Msg encodes a LES message that delivers reply data for a request
|
||||||
|
|
|
||||||
|
|
@ -610,13 +610,13 @@ func (r *TxStatusRequest) Validate(db ethdb.Database, msg *Msg) error {
|
||||||
//We retrieve transaction status, block hash and block index from a full node by a given transaction hash
|
//We retrieve transaction status, block hash and block index from a full node by a given transaction hash
|
||||||
//These information retrieve from full node is lacking of relevant data to verify
|
//These information retrieve from full node is lacking of relevant data to verify
|
||||||
//My current solution is (Code at odr_util.go):
|
//My current solution is (Code at odr_util.go):
|
||||||
//Only start verification after it's been "included", to proof a transaction is valid:
|
//Only start verification after it's been "included", to proof a transaction is valid:
|
||||||
//Retrieve BlockHash/BlockIndex -> Retrieve and verify BlockBody -> Verify given transaction hash whether included
|
//Retrieve BlockHash/BlockIndex -> Retrieve and verify BlockBody -> Verify given transaction hash whether included
|
||||||
|
|
||||||
//Need support verify through pending transactions
|
//Need support verify through pending transactions
|
||||||
//Share your ideas!
|
//Share your ideas!
|
||||||
|
|
||||||
status := msg.Obj.([]txStatus)[0]
|
status := msg.Obj.([]txStatus)[0]
|
||||||
|
|
||||||
r.TxStatus = status.Status
|
r.TxStatus = status.Status
|
||||||
r.TxEntry = status.Lookup
|
r.TxEntry = status.Lookup
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,8 @@ func (req *BloomRequest) StoreResult(db ethdb.Database) {
|
||||||
type TxStatusRequest struct {
|
type TxStatusRequest struct {
|
||||||
OdrRequest
|
OdrRequest
|
||||||
TxHash common.Hash
|
TxHash common.Hash
|
||||||
TxStatus core.TxStatus
|
TxStatus core.TxStatus
|
||||||
TxEntry *rawdb.TxLookupEntry
|
TxEntry *rawdb.TxLookupEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req *TxStatusRequest) StoreResult(db ethdb.Database) {
|
func (req *TxStatusRequest) StoreResult(db ethdb.Database) {
|
||||||
|
|
|
||||||
|
|
@ -235,35 +235,35 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi
|
||||||
//Message of the LES/2 protocol version (LPV2)
|
//Message of the LES/2 protocol version (LPV2)
|
||||||
func GetTxStatus(ctx context.Context, odr OdrBackend, txHash common.Hash) (core.TxStatus, error) {
|
func GetTxStatus(ctx context.Context, odr OdrBackend, txHash common.Hash) (core.TxStatus, error) {
|
||||||
|
|
||||||
// Return "Included" status if query success from database
|
// Return "Included" status if query success from database
|
||||||
bHash, bIndex, _ := rawdb.ReadTxLookupEntry(odr.Database(), txHash)
|
bHash, bIndex, _ := rawdb.ReadTxLookupEntry(odr.Database(), txHash)
|
||||||
if bHash != (common.Hash{}) {
|
if bHash != (common.Hash{}) {
|
||||||
return core.TxStatusIncluded, nil
|
return core.TxStatusIncluded, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send on-demand request message
|
// Send on-demand request message
|
||||||
r := &TxStatusRequest{TxHash: txHash}
|
r := &TxStatusRequest{TxHash: txHash}
|
||||||
if err := odr.Retrieve(ctx, r); err != nil {
|
if err := odr.Retrieve(ctx, r); err != nil {
|
||||||
return core.TxStatusUnknown, err
|
return core.TxStatusUnknown, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.TxStatus != core.TxStatusIncluded {
|
if r.TxStatus != core.TxStatusIncluded {
|
||||||
return r.TxStatus, nil
|
return r.TxStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Another on-demand request message for retrieve block body, verify block body internally
|
// Another on-demand request message for retrieve block body, verify block body internally
|
||||||
bHash, bIndex, _ = r.TxEntry.BlockHash, r.TxEntry.BlockIndex, r.TxEntry.Index
|
bHash, bIndex, _ = r.TxEntry.BlockHash, r.TxEntry.BlockIndex, r.TxEntry.Index
|
||||||
bBody, err := GetBody(ctx, odr, bHash, bIndex)
|
bBody, err := GetBody(ctx, odr, bHash, bIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.TxStatus, err
|
return r.TxStatus, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find matched transaction by given hash, verifying transaction by given hash whether exist
|
// Try to find matched transaction by given hash, verifying transaction by given hash whether exist
|
||||||
for _, tx := range bBody.Transactions {
|
for _, tx := range bBody.Transactions {
|
||||||
if tx.Hash() == r.TxHash {
|
if tx.Hash() == r.TxHash {
|
||||||
// Write into database if hash matched, link given hash to verified block hash and index
|
// Write into database if hash matched, link given hash to verified block hash and index
|
||||||
rawdb.WriteTxLookupEntry(odr.Database(), r.TxEntry, r.TxHash)
|
rawdb.WriteTxLookupEntry(odr.Database(), r.TxEntry, r.TxHash)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue