diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-13 03:42:14 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-13 03:42:14 +0800 |
commit | 33f066910021bc4969f4d564fc1648f6769ee3ec (patch) | |
tree | 8e02cd187b0d1d3e38c832a6e2861a1985820fcd /packages/sol-cov/src/trace_collection_subprovider.ts | |
parent | 787015f5370718e31c7990446fb1da298ed13e6b (diff) | |
download | dexon-0x-contracts-33f066910021bc4969f4d564fc1648f6769ee3ec.tar.gz dexon-0x-contracts-33f066910021bc4969f4d564fc1648f6769ee3ec.tar.zst dexon-0x-contracts-33f066910021bc4969f4d564fc1648f6769ee3ec.zip |
Refactor sol-cov to avoid keeping traceInfo in memory
Diffstat (limited to 'packages/sol-cov/src/trace_collection_subprovider.ts')
-rw-r--r-- | packages/sol-cov/src/trace_collection_subprovider.ts | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/packages/sol-cov/src/trace_collection_subprovider.ts b/packages/sol-cov/src/trace_collection_subprovider.ts index fe73546e8..5e90e3907 100644 --- a/packages/sol-cov/src/trace_collection_subprovider.ts +++ b/packages/sol-cov/src/trace_collection_subprovider.ts @@ -29,12 +29,11 @@ export interface TraceCollectionSubproviderConfig { * This class implements the [web3-provider-engine](https://github.com/MetaMask/provider-engine) subprovider interface. * It collects traces of all transactions that were sent and all calls that were executed through JSON RPC. */ -export class TraceCollectionSubprovider extends Subprovider { +export abstract class TraceCollectionSubprovider extends Subprovider { // Lock is used to not accept normal transactions while doing call/snapshot magic because they'll be reverted later otherwise private _lock = new Lock(); private _defaultFromAddress: string; private _web3Wrapper!: Web3Wrapper; - private _traceInfos: TraceInfo[] = []; private _isEnabled = true; private _config: TraceCollectionSubproviderConfig; /** @@ -47,12 +46,6 @@ export class TraceCollectionSubprovider extends Subprovider { this._config = config; } /** - * Returns all trace infos collected by the subprovider so far - */ - public getCollectedTraceInfos(): TraceInfo[] { - return this._traceInfos; - } - /** * Starts trace collection */ public start(): void { @@ -65,6 +58,11 @@ export class TraceCollectionSubprovider extends Subprovider { this._isEnabled = false; } /** + * Called for each subtrace. + * @param traceInfo Trace info for this subtrace. + */ + public abstract handleTraceInfoAsync(traceInfo: TraceInfo): Promise<void>; + /** * This method conforms to the web3-provider-engine interface. * It is called internally by the ProviderEngine when it is this subproviders * turn to handle a JSON RPC request. @@ -192,7 +190,7 @@ export class TraceCollectionSubprovider extends Subprovider { runtimeBytecode, }; } - this._traceInfos.push(traceInfo); + this.handleTraceInfoAsync(traceInfo); } } else { for (const subcallAddress of subcallAddresses) { @@ -204,7 +202,7 @@ export class TraceCollectionSubprovider extends Subprovider { address: subcallAddress, runtimeBytecode, }; - this._traceInfos.push(traceInfo); + this.handleTraceInfoAsync(traceInfo); } } } |