-
Notifications
You must be signed in to change notification settings - Fork 85
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
Conversation
classicalliu
commented
Aug 13, 2019
•
edited
Loading
edited
- impl sync by indexer RPCs
- auto use indexer mode when indexer RPCs is available
Holding this to prevent from merging while we review and test this feature. |
There was a problem hiding this 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.
@@ -55,6 +55,16 @@ export default class GetBlocks { | |||
return block | |||
} | |||
|
|||
public getTransaction = async (hash: string): Promise<CKBComponents.TransactionWithStatus> => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about IndexerQueue
There was a problem hiding this comment.
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.
// stop all blocks service | ||
if (blockListener) { | ||
await blockListener.stopAndWait() | ||
export const testIndexer = async (url: string): Promise<boolean> => { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Co-Authored-By: James Chen <[email protected]>