liuchengxu / liuchengxu/blockchain-tutorial

第三章的AddBlock

Open
#21 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
2.5k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

开头从数据库取最后一个块的hash是多余的 因为tip已经指向了
`
var lastHash []byte

// 首先获取最后一个块的哈希用于生成新块的哈希
err := bc.db.View(func(tx *bolt.Tx) error {
b := tx.Bucket([]byte(blocksBucket))
lastHash = b.Get([]byte("l"))

return nil
})

if err != nil {
log.Panic(err)
}
`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the Chapter 3 AddBlock entry point and locate the shown database read that retrieves the last block hash from the blocks bucket. Confirm how tip is already used there, then remove the redundant lookup while preserving new-block hash generation.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
blockchain
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.