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

blockchain: Fix typo #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

// Blockchain settings. These are kindof Bitcoin specific, but not contained in
// chaincfg.Params so they'll go here. If you're into the [ANN]altcoin scene,
// you may want to paramaterize these constants.
// you may want to parameterize these constants.
const (
targetTimespan = time.Hour * 24 * 14
targetSpacing = time.Minute * 10
Expand All @@ -32,10 +32,10 @@ var OrphanHeaderError = errors.New("header does not extend any known headers")

// Wrapper around Headers implementation that handles all blockchain operations
type Blockchain struct {
lock *sync.Mutex
params *chaincfg.Params
db Headers
crationDate time.Time
lock *sync.Mutex
params *chaincfg.Params
db Headers
creationDate time.Time
}

func NewBlockchain(filePath string, walletCreationDate time.Time, params *chaincfg.Params) (*Blockchain, error) {
Expand All @@ -44,10 +44,10 @@ func NewBlockchain(filePath string, walletCreationDate time.Time, params *chainc
return nil, err
}
b := &Blockchain{
lock: new(sync.Mutex),
params: params,
db: hdb,
crationDate: walletCreationDate,
lock: new(sync.Mutex),
params: params,
db: hdb,
creationDate: walletCreationDate,
}

h, err := b.db.Height()
Expand Down Expand Up @@ -82,7 +82,7 @@ func (b *Blockchain) CommitHeader(header wire.BlockHeader) (bool, *StoredHeader,
var parentHeader StoredHeader

// If the tip is also the parent of this header, then we can save a database read by skipping
// the lookup of the parent header. Otherwise (ophan?) we need to fetch the parent.
// the lookup of the parent header. Otherwise (orphan?) we need to fetch the parent.
if header.PrevBlock.IsEqual(&tipHash) {
parentHeader = bestHeader
} else {
Expand Down Expand Up @@ -146,7 +146,7 @@ func (b *Blockchain) CheckHeader(header wire.BlockHeader, prevHeader StoredHeade
if !b.params.ReduceMinDifficulty {
diffTarget, err := b.calcRequiredWork(header, int32(height+1), prevHeader)
if err != nil {
log.Errorf("Error calclating difficulty", err)
log.Errorf("Error calculating difficulty", err)
return false
}
if header.Bits != diffTarget {
Expand Down Expand Up @@ -345,7 +345,7 @@ func (b *Blockchain) GetCommonAncestor(bestHeader, prevBestHeader StoredHeader)
func (b *Blockchain) Rollback(t time.Time) error {
b.lock.Lock()
defer b.lock.Unlock()
checkpoint := GetCheckpoint(b.crationDate, b.params)
checkpoint := GetCheckpoint(b.creationDate, b.params)
checkPointHash := checkpoint.Header.BlockHash()
sh, err := b.db.GetBestHeader()
if err != nil {
Expand Down Expand Up @@ -412,7 +412,7 @@ func checkProofOfWork(header wire.BlockHeader, p *chaincfg.Params) bool {

// The target must more than 0. Why can you even encode negative...
if target.Sign() <= 0 {
log.Debugf("Block target %064x is neagtive(??)\n", target.Bytes())
log.Debugf("Block target %064x is negative(??)\n", target.Bytes())
return false
}
// The target must be less than the maximum allowed (difficulty 1)
Expand Down