Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
zistvan-public
StreamChain Prototype
Commits
f9318cdf
Commit
f9318cdf
authored
Jul 05, 2017
by
Jonathan Levi (HACERA)
Committed by
Gerrit Code Review
Jul 05, 2017
Browse files
Merge "[FAB-5165] Optimize block verification"
parents
a2f91c59
6d56e6eb
Changes
2
Hide whitespace changes
Inline
Side-by-side
gossip/gossip/channel/channel.go
View file @
f9318cdf
...
...
@@ -420,6 +420,10 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) {
gc
.
logger
.
Warning
(
"Payload is empty, got it from"
,
msg
.
GetConnectionInfo
()
.
ID
)
return
}
// Would this block go into the message store if it was verified?
if
!
gc
.
blockMsgStore
.
CheckValid
(
msg
.
GetGossipMessage
())
{
return
}
if
!
gc
.
verifyBlock
(
m
.
GossipMessage
,
msg
.
GetConnectionInfo
()
.
ID
)
{
gc
.
logger
.
Warning
(
"Failed verifying block"
,
m
.
GetDataMsg
()
.
Payload
.
SeqNum
)
return
...
...
@@ -468,6 +472,10 @@ func (gc *gossipChannel) HandleMessage(msg proto.ReceivedMessage) {
gc
.
logger
.
Warning
(
"DataUpdate message contains item with channel"
,
gMsg
.
Channel
,
"but should be"
,
gc
.
chainID
)
return
}
// Would this block go into the message store if it was verified?
if
!
gc
.
blockMsgStore
.
CheckValid
(
msg
.
GetGossipMessage
())
{
return
}
if
!
gc
.
verifyBlock
(
gMsg
.
GossipMessage
,
msg
.
GetConnectionInfo
()
.
ID
)
{
return
}
...
...
gossip/gossip/gossip_impl.go
View file @
f9318cdf
...
...
@@ -437,26 +437,6 @@ func (g *gossipServiceImpl) validateMsg(msg proto.ReceivedMessage) bool {
}
}
if
msg
.
GetGossipMessage
()
.
IsDataMsg
()
{
blockMsg
:=
msg
.
GetGossipMessage
()
.
GetDataMsg
()
if
blockMsg
.
Payload
==
nil
{
g
.
logger
.
Warning
(
"Empty block! Discarding it"
)
return
false
}
// If we're configured to skip block validation, don't verify it
if
g
.
conf
.
SkipBlockVerification
{
return
true
}
seqNum
:=
blockMsg
.
Payload
.
SeqNum
rawBlock
:=
blockMsg
.
Payload
.
Data
if
err
:=
g
.
mcs
.
VerifyBlock
(
msg
.
GetGossipMessage
()
.
Channel
,
seqNum
,
rawBlock
);
err
!=
nil
{
g
.
logger
.
Warning
(
"Could not verify block"
,
blockMsg
.
Payload
.
SeqNum
,
":"
,
err
)
return
false
}
}
if
msg
.
GetGossipMessage
()
.
IsStateInfoMsg
()
{
if
err
:=
g
.
validateStateInfoMsg
(
msg
.
GetGossipMessage
());
err
!=
nil
{
g
.
logger
.
Warning
(
"StateInfo message"
,
msg
,
"is found invalid:"
,
err
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment