-
Notifications
You must be signed in to change notification settings - Fork 228
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
Memorize hash #549
Comments
SummaryI think, only All others can be found be a shell command: yangby@laptop:ckb> grep -r 'fn [a-z_]*hash(' [^t]* | grep "[-]> [^&]*H256"
core/src/header.rs: pub fn pow_hash(&self) -> H256 {
core/src/header.rs: pub fn pow_hash(&self) -> H256 {
core/src/script.rs: pub fn hash(&self) -> H256 {
core/src/block.rs: pub fn cal_uncles_hash(&self) -> H256 {
core/src/uncle.rs:pub fn uncles_hash(uncles: &[UncleBlock]) -> H256 {
core/src/transaction.rs: pub fn data_hash(&self) -> H256 {
core/src/transaction.rs: pub fn hash(&self) -> H256 {
rpc/src/module/chain.rs: fn get_block_hash(&self, _number: String) -> Result<Option<H256>>;
rpc/src/module/chain.rs: fn get_block_hash(&self, number: String) -> Result<Option<H256>> {
shared/src/shared.rs: fn block_hash(&self, number: BlockNumber) -> Option<H256> {
store/src/store.rs: fn get_block_hash(&self, number: BlockNumber) -> Option<H256>;
store/src/store.rs: fn get_block_hash(&self, number: BlockNumber) -> Option<H256> {
sync/src/types.rs: pub fn block_hash(&self, number: BlockNumber) -> Option<H256> {
verification/src/tests/dummy.rs: fn block_hash(&self, _height: u64) -> Option<H256> { FurtherI think we can optimize the hash of Lines 408 to 409 in de1cfc9
Lines 457 to 459 in de1cfc9
Lines 90 to 98 in de1cfc9
Lines 43 to 51 in de1cfc9
My suggest is: pub fn hash(&self) -> H256 {
let mut h = H256::zero();
h.as_bytes_mut()[..self.0.len()].copy_from_slice(&self.0[..]);
h
} |
Add |
Header
andTransaction
) since they are constructed.ProposalShortId::hash()
.Transaction
into database.So, we can just fetch them from database instead of compute them.
The text was updated successfully, but these errors were encountered: