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: sync by indexer RPCs #863

Merged
merged 18 commits into from
Aug 19, 2019
Merged

feat: sync by indexer RPCs #863

merged 18 commits into from
Aug 19, 2019

Conversation

classicalliu
Copy link
Contributor

@classicalliu classicalliu commented Aug 13, 2019

  • impl sync by indexer RPCs
  • auto use indexer mode when indexer RPCs is available

@classicalliu classicalliu marked this pull request as ready for review August 14, 2019 08:56
@classicalliu classicalliu requested a review from ashchan August 14, 2019 08:56
@ashchan
Copy link
Contributor

ashchan commented Aug 14, 2019

Holding this to prevent from merging while we review and test this feature.

@ashchan ashchan changed the title feat: sync by indexer RPCs [HOLD]feat: sync by indexer RPCs Aug 14, 2019
nervos-bot[bot]
nervos-bot bot previously requested changes Aug 14, 2019
Copy link

@nervos-bot nervos-bot bot left a comment

Choose a reason for hiding this comment

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

Hold as requested by @ashchan.

@ashchan ashchan self-assigned this Aug 14, 2019
@ashchan ashchan requested a review from shaojunda August 16, 2019 01:34
@ashchan ashchan changed the title [HOLD]feat: sync by indexer RPCs feat: sync by indexer RPCs Aug 16, 2019
@nervos-bot nervos-bot bot dismissed their stale review August 16, 2019 01:34

Unhold as requested by @ashchan.

@@ -55,6 +55,16 @@ export default class GetBlocks {
return block
}

public getTransaction = async (hash: string): Promise<CKBComponents.TransactionWithStatus> => {

Choose a reason for hiding this comment

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

should getTransaction be placed in a separate file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need, it's block info too.


if (
txPoint &&
(BigInt(txPoint.blockNumber) >= startBlockNumber || this.tipBlockNumber - BigInt(txPoint.blockNumber) < 1000)

Choose a reason for hiding this comment

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

Is it possible to extract this expression into a method?

Copy link
Contributor Author

@classicalliu classicalliu Aug 16, 2019

Choose a reason for hiding this comment

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

No need, only use once.

await this.indexLockHashes(lockHashes)
this.indexed = true
}
const minBlockNumber = await this.getCurrentBlockNumber(lockHashes)

Choose a reason for hiding this comment

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

What is the difference between currentBlockNumber and minBlockNumber?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

minBlockNumber means the min block number in get_lock_hash_index_states of all lock hashes.

@@ -48,4 +48,20 @@ export default class Utils {
}
return result
}

public static min = (array: bigint[]): bigint | undefined => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would a numeric operation belong to sync/utils?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Utility methods of sync module.

ConsumedBy = 'consumedBy',
}

export default class Queue {
Copy link
Contributor

Choose a reason for hiding this comment

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

While I understand we have different folders - to some extend they act like namespaces, having multiple Queue classes worries me that it could confuse reading and understanding our design and implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about IndexerQueue

Copy link
Contributor

Choose a reason for hiding this comment

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

That's better. We have two queue implementations for two different modules, then we name them differently for clarification. Please do so.

packages/neuron-wallet/src/startup/sync-block-task/task.ts Outdated Show resolved Hide resolved
packages/neuron-wallet/src/startup/sync-block-task/task.ts Outdated Show resolved Hide resolved
// stop all blocks service
if (blockListener) {
await blockListener.stopAndWait()
export const testIndexer = async (url: string): Promise<boolean> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be more clearer to name it such as isIndexerEnabled or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@classicalliu classicalliu merged commit 6f3b695 into develop Aug 19, 2019
@ashchan ashchan deleted the impl-indexer branch August 22, 2019 08:58
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