Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store: adding transactions & receipts columns to cold storage #7943

Merged
merged 9 commits into from
Oct 27, 2022

Conversation

posvyatokum
Copy link
Member

No description provided.

@posvyatokum posvyatokum requested a review from mina86 October 27, 2022 11:45
@posvyatokum posvyatokum requested a review from a team as a code owner October 27, 2022 11:45
Comment on lines 146 to 152
let chunks = {
let mut chunks: Vec<ShardChunk> = vec![];
for chunk_header in block.chunks().iter() {
chunks.push(store.get_ser_or_err(DBCol::Chunks, chunk_header.chunk_hash().as_bytes())?);
}
chunks
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let chunks = {
let mut chunks: Vec<ShardChunk> = vec![];
for chunk_header in block.chunks().iter() {
chunks.push(store.get_ser_or_err(DBCol::Chunks, chunk_header.chunk_hash().as_bytes())?);
}
chunks
};
let chunks = block.chunks().iter().map(|chunk_header| {
store.get_ser_or_err(DBCol::Chunks, chunk_header.chunk_hash().as_bytes())
}).collect::<Result<Vec<_>, _>()?;

should work

Comment on lines 214 to 236
let mut outcomes: Vec<Vec<CryptoHash>> = vec![];
for shard_id in 0..shard_layout.num_shards() {
debug_assert_eq!(
DBCol::OutcomeIds.key_type(),
&[DBKeyType::BlockHash, DBKeyType::ShardId]
);

outcomes.push(
store
.get_ser(
DBCol::OutcomeIds,
&join_two_keys(
&block_hash_key,
&shard_id.to_le_bytes().to_vec(),
),
)?
.unwrap_or_default(),
);
}
outcomes
.iter()
.flat_map(|os| os.iter().map(|o| o.as_bytes().to_vec()))
.collect()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do to_vec in &shard_id.to_le_bytes().to_vec(). Furthermore,

Suggested change
let mut outcomes: Vec<Vec<CryptoHash>> = vec![];
for shard_id in 0..shard_layout.num_shards() {
debug_assert_eq!(
DBCol::OutcomeIds.key_type(),
&[DBKeyType::BlockHash, DBKeyType::ShardId]
);
outcomes.push(
store
.get_ser(
DBCol::OutcomeIds,
&join_two_keys(
&block_hash_key,
&shard_id.to_le_bytes().to_vec(),
),
)?
.unwrap_or_default(),
);
}
outcomes
.iter()
.flat_map(|os| os.iter().map(|o| o.as_bytes().to_vec()))
.collect()
debug_assert_eq!(
DBCol::OutcomeIds.key_type(),
&[DBKeyType::BlockHash, DBKeyType::ShardId]
);
(0..shard_layout.num_shards())
.map(|shard_id| {
Ok(store
.get_ser::<Vec<CryptoHash>>(
DBCol::OutcomeIds,
&join_two_keys(
&block_hash_key,
&shard_id.to_le_bytes(),
),
)?
.unwrap_or_default())
})
.collect::<Result<Vec<_>, _>()?
.into_iter()
.flat_map(|hashes| hashes.into_iter().map(|hash| hash.as_bytes().to_vec()))
.collect()

Might need to add some more types somewhere but should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants