diff --git a/core/rawdb/accessors_indexes.go b/core/rawdb/accessors_indexes.go index fcb06a3a52..cefb58161e 100644 --- a/core/rawdb/accessors_indexes.go +++ b/core/rawdb/accessors_indexes.go @@ -58,13 +58,13 @@ 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) - } + 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. diff --git a/eth/api_backend.go b/eth/api_backend.go index 68b5bbddfa..74053802fa 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -17,8 +17,8 @@ package eth import ( - "errors" "context" + "errors" "math/big" "github.com/ethereum/go-ethereum/accounts" diff --git a/internal/ethapi/backend.go b/internal/ethapi/backend.go index 302192910c..011600ce14 100644 --- a/internal/ethapi/backend.go +++ b/internal/ethapi/backend.go @@ -66,7 +66,7 @@ type Backend interface { Stats() (pending int, queued int) TxPoolContent() (map[common.Address]types.Transactions, map[common.Address]types.Transactions) 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 CurrentBlock() *types.Block diff --git a/les/handler.go b/les/handler.go index 397b623a93..b055dc4fc7 100644 --- a/les/handler.go +++ b/les/handler.go @@ -1109,7 +1109,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { p.fcServer.GotReply(resp.ReqID, resp.BV) - deliverMsg = &Msg{ + deliverMsg = &Msg{ MsgType: MsgTxStatus, ReqID: resp.ReqID, Obj: resp.Status, diff --git a/les/odr.go b/les/odr.go index f9a56e464a..7af5a688b2 100644 --- a/les/odr.go +++ b/les/odr.go @@ -77,7 +77,7 @@ const ( MsgProofsV2 MsgHeaderProofs MsgHelperTrieProofs - MsgTxStatus + MsgTxStatus ) // Msg encodes a LES message that delivers reply data for a request diff --git a/les/odr_requests.go b/les/odr_requests.go index 7900929434..12e1aff063 100644 --- a/les/odr_requests.go +++ b/les/odr_requests.go @@ -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 //These information retrieve from full node is lacking of relevant data to verify //My current solution is (Code at odr_util.go): - //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 + //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 - //Need support verify through pending transactions - //Share your ideas! + //Need support verify through pending transactions + //Share your ideas! - status := msg.Obj.([]txStatus)[0] + status := msg.Obj.([]txStatus)[0] r.TxStatus = status.Status r.TxEntry = status.Lookup diff --git a/light/odr.go b/light/odr.go index a0f27a075c..cffd75d03f 100644 --- a/light/odr.go +++ b/light/odr.go @@ -174,8 +174,8 @@ func (req *BloomRequest) StoreResult(db ethdb.Database) { type TxStatusRequest struct { OdrRequest TxHash common.Hash - TxStatus core.TxStatus - TxEntry *rawdb.TxLookupEntry + TxStatus core.TxStatus + TxEntry *rawdb.TxLookupEntry } func (req *TxStatusRequest) StoreResult(db ethdb.Database) { diff --git a/light/odr_util.go b/light/odr_util.go index 54201760e2..7126ddd7ad 100644 --- a/light/odr_util.go +++ b/light/odr_util.go @@ -235,35 +235,35 @@ func GetBloomBits(ctx context.Context, odr OdrBackend, bitIdx uint, sectionIdxLi //Message of the LES/2 protocol version (LPV2) func GetTxStatus(ctx context.Context, odr OdrBackend, txHash common.Hash) (core.TxStatus, error) { - // Return "Included" status if query success from database - bHash, bIndex, _ := rawdb.ReadTxLookupEntry(odr.Database(), txHash) - if bHash != (common.Hash{}) { + // Return "Included" status if query success from database + bHash, bIndex, _ := rawdb.ReadTxLookupEntry(odr.Database(), txHash) + if bHash != (common.Hash{}) { return core.TxStatusIncluded, nil - } + } - // Send on-demand request message + // Send on-demand request message r := &TxStatusRequest{TxHash: txHash} if err := odr.Retrieve(ctx, r); err != nil { return core.TxStatusUnknown, err } - if r.TxStatus != core.TxStatusIncluded { + if r.TxStatus != core.TxStatusIncluded { return r.TxStatus, nil } // Another on-demand request message for retrieve block body, verify block body internally 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 { 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 { if tx.Hash() == r.TxHash { - // Write into database if hash matched, link given hash to verified block hash and index - rawdb.WriteTxLookupEntry(odr.Database(), r.TxEntry, r.TxHash) - break + // Write into database if hash matched, link given hash to verified block hash and index + rawdb.WriteTxLookupEntry(odr.Database(), r.TxEntry, r.TxHash) + break } }