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

feat: add GetMaxMatureBlockNumber func #26

Merged
merged 9 commits into from
Apr 8, 2021

Conversation

shaojunda
Copy link
Contributor

No description provided.

utils/util.go Outdated
numer uint64
// Denominator.
denom uint64
}
Copy link

Choose a reason for hiding this comment

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

Replace rationalNumber with big.Rat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: baf0fec

tipEpochRN, cellbaseMaturityRN := epochRationalNum(tipEpoch, cellbaseMaturity)
if tipEpochRN.numer-cellbaseMaturityRN.numer < 0 {
return true
}
Copy link

Choose a reason for hiding this comment

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

Use big.Rat instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: baf0fec

utils/util.go Outdated
Comment on lines 171 to 176
nodeVersion := strings.Split(nodeInfo.Version, " (")
versionArr := strings.Split(nodeVersion[0], ".")
major, err := strconv.Atoi(versionArr[0])
minor, err := strconv.Atoi(versionArr[1])
patch, err := strconv.Atoi(versionArr[2])
return major, minor, patch, nil
Copy link

Choose a reason for hiding this comment

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

Suggested change
nodeVersion := strings.Split(nodeInfo.Version, " (")
versionArr := strings.Split(nodeVersion[0], ".")
major, err := strconv.Atoi(versionArr[0])
minor, err := strconv.Atoi(versionArr[1])
patch, err := strconv.Atoi(versionArr[2])
return major, minor, patch, nil
nodeVersion := strings.Split(nodeInfo.Version, " (")
versionArr := strings.Split(nodeVersion[0], ".")
major, err := strconv.Atoi(versionArr[0])
minor, err := strconv.Atoi(versionArr[1])
patch, err := strconv.Atoi(versionArr[2])
return major, minor, patch, nil

Put above line in a standalone function and test it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: 02abcd5

README.md Outdated
ScriptType: indexer.ScriptTypeLock,
Filter: &indexer.CellsFilter{
BlockRange: &[2]uint64{0, maxMatureBlockNumber},
},
Copy link

@TheWaWaR TheWaWaR Apr 1, 2021

Choose a reason for hiding this comment

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

The filter is wrong, must only filter out cellbase, and cellbase not in genesis block.

https://github.com/nervosnetwork/ckb-cli/blob/346663deff6f7acc65fea34ff59e238c39f2043d/src/utils/other.rs#L339-L345

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: 54e135a e0b1f74

@shaojunda shaojunda requested a review from TheWaWaR April 6, 2021 08:55

// IsMature check if a cellbase live cell is mature
func IsMature(cell *indexer.LiveCell, maxMatureBlockNumber uint64) bool {
return cell.TxIndex > 0 || cell.BlockNumber == 0 || cell.BlockNumber <= maxMatureBlockNumber
Copy link

Choose a reason for hiding this comment

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

What is cell.TxIndex here mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as here: https://github.com/nervosnetwork/ckb-indexer/blob/master/src/service.rs#L235

means transaction index in the block.

@shaojunda shaojunda requested a review from TheWaWaR April 6, 2021 09:42
README.md Outdated
}
if utils.IsMature(liveCell, maxMatureBlockNumber) {
cells = append(cells, liveCell)
}
Copy link

@TheWaWaR TheWaWaR Apr 7, 2021

Choose a reason for hiding this comment

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

Mixed use of <space> and <tab>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: b607158

@shaojunda shaojunda force-pushed the shaojunda-add-mature-block-range-sample branch from e0b1f74 to 48474f1 Compare April 7, 2021 02:42
@shaojunda shaojunda force-pushed the shaojunda-add-mature-block-range-sample branch from 48474f1 to b607158 Compare April 7, 2021 02:46
@shaojunda shaojunda force-pushed the shaojunda-add-mature-block-range-sample branch from 1a206cd to b607158 Compare April 8, 2021 11:56
@shaojunda shaojunda merged commit 4d76309 into develop Apr 8, 2021
@shaojunda shaojunda deleted the shaojunda-add-mature-block-range-sample branch April 8, 2021 12:02
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.

3 participants