This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PV63 receipts response #687
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e970dd4
client state data func
NikVolf da6f6d5
state data query to client
NikVolf 3495847
redundant lines
NikVolf 19f23f8
increasing history to be useful for geth fast sync
NikVolf fb51ac0
blockchain receipts rlp generation
NikVolf ade8b83
Merge branch 'master' into pv63-state
NikVolf bd9cfb4
Merge branch 'pv63-state' into pv63-receipts
NikVolf 0684abd
fixed to return receipts grouped by requested block
NikVolf 809c239
fix rev
NikVolf 8f4323f
Merge branch 'master' into pv63-receipts
NikVolf 8cdb013
Merge branch 'master' into pv63-receipts
NikVolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ const MAX_BODIES_TO_SEND: usize = 256; | |
const MAX_HEADERS_TO_SEND: usize = 512; | ||
const MAX_NODE_DATA_TO_SEND: usize = 1024; | ||
const MAX_RECEIPTS_TO_SEND: usize = 1024; | ||
const MAX_RECEIPTS_HEADERS_TO_SEND: usize = 16; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why so small? |
||
const MAX_HEADERS_TO_REQUEST: usize = 512; | ||
const MAX_BODIES_TO_REQUEST: usize = 256; | ||
const MIN_PEERS_PROPAGATION: usize = 4; | ||
|
@@ -1060,17 +1061,20 @@ impl ChainSync { | |
debug!(target: "sync", "Empty GetReceipts request, ignoring."); | ||
return Ok(None); | ||
} | ||
count = min(count, MAX_RECEIPTS_TO_SEND); | ||
let mut added = 0usize; | ||
count = min(count, MAX_RECEIPTS_HEADERS_TO_SEND); | ||
let mut added_headers = 0usize; | ||
let mut added_receipts = 0usize; | ||
let mut data = Bytes::new(); | ||
for i in 0..count { | ||
if let Some(mut hdr) = io.chain().block_receipts(&try!(rlp.val_at::<H256>(i))) { | ||
data.append(&mut hdr); | ||
added += 1; | ||
if let Some(mut receipts_bytes) = io.chain().block_receipts(&try!(rlp.val_at::<H256>(i))) { | ||
data.append(&mut receipts_bytes); | ||
added_receipts += receipts_bytes.len(); | ||
added_headers += 1; | ||
if added_receipts > MAX_RECEIPTS_TO_SEND { break; } | ||
} | ||
} | ||
let mut rlp_result = RlpStream::new_list(added); | ||
rlp_result.append_raw(&data, added); | ||
let mut rlp_result = RlpStream::new_list(added_headers); | ||
rlp_result.append_raw(&data, added_headers); | ||
Ok(Some((RECEIPTS_PACKET, rlp_result))) | ||
} | ||
|
||
|
@@ -1396,7 +1400,7 @@ mod tests { | |
assert!(rlp_result.is_some()); | ||
|
||
// the length of two rlp-encoded receipts | ||
assert_eq!(597, rlp_result.unwrap().1.out().len()); | ||
assert_eq!(603, rlp_result.unwrap().1.out().len()); | ||
|
||
let mut sync = dummy_sync_with_peer(H256::new()); | ||
io.sender = Some(2usize); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
self.chain.block_receipts(hash).map(rlp::encode)
is shorter