core, eth, les, trie: add a prefix to contract code (#21080)
This commit is contained in:
@ -608,7 +608,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
||||
return errResp(ErrDecode, "msg %v: %v", msg, err)
|
||||
}
|
||||
// Retrieve the requested state entry, stopping if enough was found
|
||||
if entry, err := pm.blockchain.TrieNode(hash); err == nil {
|
||||
// todo now the code and trienode is mixed in the protocol level,
|
||||
// separate these two types.
|
||||
entry, err := pm.blockchain.TrieNode(hash)
|
||||
if len(entry) == 0 || err != nil {
|
||||
// Read the contract code with prefix only to save unnecessary lookups.
|
||||
entry, err = pm.blockchain.ContractCodeWithPrefix(hash)
|
||||
}
|
||||
if err == nil && len(entry) > 0 {
|
||||
data = append(data, entry)
|
||||
bytes += len(entry)
|
||||
}
|
||||
@ -703,7 +710,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
|
||||
log.Warn("Propagated block has invalid uncles", "have", hash, "exp", request.Block.UncleHash())
|
||||
break // TODO(karalabe): return error eventually, but wait a few releases
|
||||
}
|
||||
if hash := types.DeriveSha(request.Block.Transactions()); hash != request.Block.TxHash() {
|
||||
if hash := types.DeriveSha(request.Block.Transactions(), new(trie.Trie)); hash != request.Block.TxHash() {
|
||||
log.Warn("Propagated block has invalid body", "have", hash, "exp", request.Block.TxHash())
|
||||
break // TODO(karalabe): return error eventually, but wait a few releases
|
||||
}
|
||||
|
Reference in New Issue
Block a user