aboutsummaryrefslogtreecommitdiffstats
path: root/eth/protocol.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-30 20:48:07 +0800
committerzelig <viktor.tron@gmail.com>2015-04-01 19:32:42 +0800
commit82da6bf4d213784cfc7ba45432f9f96c2d6b4d9d (patch)
tree6d286d1ba2aad4234efd16f87024f287ce12106a /eth/protocol.go
parentd677190f3916c5bee276d9abba69814022ab967f (diff)
downloaddexon-82da6bf4d213784cfc7ba45432f9f96c2d6b4d9d.tar.gz
dexon-82da6bf4d213784cfc7ba45432f9f96c2d6b4d9d.tar.zst
dexon-82da6bf4d213784cfc7ba45432f9f96c2d6b4d9d.zip
test for invalid rlp encoding of block in BlocksMsg
- rename Validate -> ValidateFields not to confure consensus block validation - add nil transaction and nil uncle header validation - remove bigint field checks: rlp already decodes *big.Int to big.NewInt(0) - add test for nil header, nil transaction
Diffstat (limited to 'eth/protocol.go')
-rw-r--r--eth/protocol.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/eth/protocol.go b/eth/protocol.go
index 0a3f67b62..f0a749d33 100644
--- a/eth/protocol.go
+++ b/eth/protocol.go
@@ -268,6 +268,9 @@ func (self *ethProtocol) handle() error {
return self.protoError(ErrDecode, "msg %v: %v", msg, err)
}
}
+ if err := block.ValidateFields(); err != nil {
+ return self.protoError(ErrDecode, "block validation %v: %v", msg, err)
+ }
self.blockPool.AddBlock(&block, self.id)
}
@@ -276,7 +279,7 @@ func (self *ethProtocol) handle() error {
if err := msg.Decode(&request); err != nil {
return self.protoError(ErrDecode, "%v: %v", msg, err)
}
- if err := request.Block.Validate(); err != nil {
+ if err := request.Block.ValidateFields(); err != nil {
return self.protoError(ErrDecode, "block validation %v: %v", msg, err)
}
hash := request.Block.Hash()