-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
430 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import SafeEventEmitter from '@metamask/safe-event-emitter'; | ||
import { JsonRpcRequest, JsonRpcResponse } from 'json-rpc-engine'; | ||
export interface Provider extends SafeEventEmitter { | ||
sendAsync: <T, U>(req: JsonRpcRequest<T>, cb: (err: Error, response: JsonRpcResponse<U>) => void) => void; | ||
} | ||
interface BaseBlockTrackerArgs { | ||
blockResetDuration?: number; | ||
} | ||
export declare abstract class BaseBlockTracker extends SafeEventEmitter { | ||
protected _isRunning: boolean; | ||
private _blockResetDuration; | ||
private _currentBlock; | ||
private _blockResetTimeout?; | ||
constructor(opts: BaseBlockTrackerArgs); | ||
destroy(): Promise<void>; | ||
isRunning(): boolean; | ||
getCurrentBlock(): string | null; | ||
getLatestBlock(): Promise<string>; | ||
removeAllListeners(eventName?: string | symbol): this; | ||
/** | ||
* To be implemented in subclass. | ||
*/ | ||
protected abstract _start(): Promise<void>; | ||
/** | ||
* To be implemented in subclass. | ||
*/ | ||
protected abstract _end(): Promise<void>; | ||
private _setupInternalEvents; | ||
private _onNewListener; | ||
private _onRemoveListener; | ||
private _maybeStart; | ||
private _maybeEnd; | ||
private _getBlockTrackerEventCount; | ||
protected _newPotentialLatest(newBlock: string): void; | ||
private _setCurrentBlock; | ||
private _setupBlockResetTimeout; | ||
private _cancelBlockResetTimeout; | ||
private _resetCurrentBlock; | ||
} | ||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { BaseBlockTracker, Provider } from './BaseBlockTracker'; | ||
export interface PollingBlockTrackerOptions { | ||
provider?: Provider; | ||
pollingInterval?: number; | ||
retryTimeout?: number; | ||
keepEventLoopActive?: boolean; | ||
setSkipCacheFlag?: boolean; | ||
blockResetDuration?: number; | ||
} | ||
export declare class PollingBlockTracker extends BaseBlockTracker { | ||
private _provider; | ||
private _pollingInterval; | ||
private _retryTimeout; | ||
private _keepEventLoopActive; | ||
private _setSkipCacheFlag; | ||
constructor(opts?: PollingBlockTrackerOptions); | ||
checkForLatestBlock(): Promise<string>; | ||
protected _start(): Promise<void>; | ||
protected _end(): Promise<void>; | ||
private _synchronize; | ||
private _updateLatestBlock; | ||
private _fetchLatestBlock; | ||
} |
Oops, something went wrong.