-
Notifications
You must be signed in to change notification settings - Fork 110
Conversation
c1035d9
to
37d04da
Compare
2fe8cf5
to
511f495
Compare
5bfdbfb
to
fa28672
Compare
@zelig @janos This is the error i get
But this is not causing a issue in when we test with the Trinity client. So i am submitting this for review. |
Co-authored-by: zelig <viktor.tron@gmail.com> Co-authored-by: jmozah <zahoor@zahoor.in>
fa28672
to
5b9c825
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor
bzzeth/bzzeth.go
Outdated
default: | ||
p.logger.Error("Invalid msg") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need for default case, p2p protocols knows about possible message types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
vhash := addresses[i] | ||
if wantHeaderFunc(vhash, b.kad) { | ||
hashes = append(hashes, vhash) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super nit picking but call wantedHeader but if not wanted we report not in proximity. so you display more specific property than granted by wantedHeaders
which can also be overwritten.
Generally code is simpler to interpret if it avoids these latent logical leaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure i understand this comment. Are you saying not to log.Trace if header is not in proximity?
bzzeth/bzzeth.go
Outdated
hdr := make([]byte, len(h)) | ||
copy(hdr, h) | ||
wg.Add(1) | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we rewrite this using errgroup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in addition, you could probably avoid the copy
operation with changing
go func() {
to go func(h []byte) {
then calling the closure with (h[:])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errGroups Go routine can onlu accept func().. so cant pass it like that..
func (g *Group) Go(f func() error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok then shadow it?
bzzeth/bzzeth.go
Outdated
req.lock.RLock() | ||
defer req.lock.RUnlock() | ||
rcvdFlag, ok = req.hashes[addr] | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return explicit values as per our guidelines :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
}) | ||
} | ||
|
||
func blockHeaderExchange(tester *p2ptest.ProtocolTester, peerID enode.ID, requestID uint32, wantedData []rlp.RawValue) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this does not seem to test much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blockHeaderExchange does not test anything from the protocol response perspective, but TestNewBlockHeaders testcase checks the effect of receiving this message. Especially see the functions checkStorage and checkDelivery.
yes, err := b.netStore.Store.HasMulti(ctx, addresses...) | ||
if err != nil { | ||
log.Error("Error checking hashesh in store", "Reason", err) | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider dropping the peer here before returning
addresses := make([]chunk.Address, len(*msg)) | ||
for i, h := range *msg { | ||
addresses[i] = h.Hash.Bytes() | ||
log.Trace("Received hashes ", "Header", hex.EncodeToString(h.Hash.Bytes())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use p.logger
instead, also in 135, remove the extra space after "hashes " and don't capitalize the words in the logger, we usually log lowercase
deliveries := make(chan []byte) | ||
req, err := p.getBlockHeaders(ctx, hashes, deliveries) | ||
if err != nil { | ||
p.logger.Error("Error sending GetBlockHeader message", "Reason", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i meant instead of Reason
write err
return | ||
} | ||
|
||
// convert rlp.RawValue to bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong comment
bzzeth/bzzeth.go
Outdated
} | ||
|
||
// convert rlp.RawValue to bytes | ||
var headers [][]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i meant it might need shadowing inside the loop. for now just make the above change with:
headers := make([][]byte, len(msg.Headers))
for i, h ... {
headers[i]=h
}
bzzeth/bzzeth.go
Outdated
hdr := make([]byte, len(h)) | ||
copy(hdr, h) | ||
wg.Add(1) | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok then shadow it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it is great now
close(errC) | ||
|
||
// Store all the valid header chunks in one shot | ||
results, err := b.netStore.Put(ctx, chunk.ModePutUpload, chunks...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need
This is failing on Appveyor with:
It's now also happening on master after being merged. |
Phase 1 does the following things
And test this with Trinity client.