@subsquid/util-internal-data-source 0.0.1-portal-api.721f49 → 0.0.1-portal-api.d0738f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +4 -7
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +6 -10
package/lib/index.d.ts
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { Range } from '@subsquid/util-internal-range';
|
|
2
1
|
export interface BlockRef {
|
|
3
2
|
number: number;
|
|
4
3
|
hash: string;
|
|
5
4
|
}
|
|
6
5
|
export interface DataSourceStreamOptions {
|
|
7
|
-
|
|
6
|
+
after?: BlockRef;
|
|
8
7
|
stopOnHead?: boolean;
|
|
9
|
-
parentHash?: string;
|
|
10
8
|
}
|
|
11
9
|
export interface BlockBatch<B> {
|
|
12
10
|
blocks: B[];
|
|
13
11
|
finalizedHead?: BlockRef;
|
|
14
12
|
}
|
|
15
|
-
export type DataSourceStream<B> = AsyncIterable<BlockBatch<B>>;
|
|
16
13
|
export interface DataSource<B> {
|
|
17
14
|
getHead(): Promise<BlockRef | undefined>;
|
|
18
15
|
getFinalizedHead(): Promise<BlockRef | undefined>;
|
|
19
|
-
getFinalizedStream(req: DataSourceStreamOptions):
|
|
20
|
-
getStream(req: DataSourceStreamOptions):
|
|
16
|
+
getFinalizedStream(req: DataSourceStreamOptions): AsyncIterable<BlockBatch<B>>;
|
|
17
|
+
getStream(req: DataSourceStreamOptions): AsyncIterable<BlockBatch<B>>;
|
|
21
18
|
}
|
|
22
19
|
export declare class ForkException extends Error {
|
|
23
20
|
readonly previousBlocks: BlockRef[];
|
|
24
21
|
readonly isSqdForkException = true;
|
|
25
|
-
constructor(
|
|
22
|
+
constructor(blockNumber: number, parentBlockHash: string, previousBlocks: BlockRef[]);
|
|
26
23
|
get name(): string;
|
|
27
24
|
}
|
|
28
25
|
export declare function isForkException(err: unknown): err is ForkException;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;CACf;AAGD,MAAM,WAAW,uBAAuB;IACpC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;CACvB;AAGD,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,MAAM,EAAE,CAAC,EAAE,CAAA;IACX,aAAa,CAAC,EAAE,QAAQ,CAAA;CAC3B;AAGD,MAAM,WAAW,UAAU,CAAC,CAAC;IACzB,OAAO,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAA;IAExC,gBAAgB,IAAI,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAA;IAGjD,kBAAkB,CAAC,GAAG,EAAE,uBAAuB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAE9E,SAAS,CAAC,GAAG,EAAE,uBAAuB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CACxE;AAGD,qBAAa,aAAc,SAAQ,KAAK;aAMhB,cAAc,EAAE,QAAQ,EAAE;IAL9C,QAAQ,CAAC,kBAAkB,QAAO;gBAG9B,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EACP,cAAc,EAAE,QAAQ,EAAE;IAO9C,IAAI,IAAI,IAAI,MAAM,CAEjB;CACJ;AAGD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,aAAa,CAElE;AAGD,qBAAa,oBAAqB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,yBAAyB,QAAO;CAC5C;AAGD,qBAAa,qBAAsB,SAAQ,oBAAoB;gBAC/C,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM;CAO/C;AAGD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,KAAK,CAEjE"}
|
package/lib/index.js
CHANGED
|
@@ -8,10 +8,10 @@ exports.isForkException = isForkException;
|
|
|
8
8
|
exports.isDataConsistencyError = isDataConsistencyError;
|
|
9
9
|
const assert_1 = __importDefault(require("assert"));
|
|
10
10
|
class ForkException extends Error {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(blockNumber, parentBlockHash, previousBlocks) {
|
|
12
12
|
(0, assert_1.default)(previousBlocks.length > 0);
|
|
13
13
|
let last = previousBlocks[previousBlocks.length - 1];
|
|
14
|
-
super(`expected ${
|
|
14
|
+
super(`expected ${blockNumber} to have parent ${last.number}#${parentBlockHash}, but got ${last.number}#${last.hash}`);
|
|
15
15
|
this.previousBlocks = previousBlocks;
|
|
16
16
|
this.isSqdForkException = true;
|
|
17
17
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAqDA,0CAEC;AAmBD,wDAEC;AA5ED,oDAA2B;AAkC3B,MAAa,aAAc,SAAQ,KAAK;IAGpC,YACI,WAAmB,EACnB,eAAuB,EACP,cAA0B;QAE1C,IAAA,gBAAM,EAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACjC,IAAI,IAAI,GAAG,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACpD,KAAK,CAAC,YAAY,WAAW,mBAAmB,IAAI,CAAC,MAAM,IAAI,eAAe,aAAa,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAJtG,mBAAc,GAAd,cAAc,CAAY;QALrC,uBAAkB,GAAG,IAAI,CAAA;IAUlC,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,eAAe,CAAA;IAC1B,CAAC;CACJ;AAhBD,sCAgBC;AAGD,SAAgB,eAAe,CAAC,GAAY;IACxC,OAAO,GAAG,YAAY,KAAK,IAAI,CAAC,CAAE,GAAW,CAAC,kBAAkB,CAAA;AACpE,CAAC;AAGD,MAAa,oBAAqB,SAAQ,KAAK;IAA/C;;QACa,8BAAyB,GAAG,IAAI,CAAA;IAC7C,CAAC;CAAA;AAFD,oDAEC;AAGD,MAAa,qBAAsB,SAAQ,oBAAoB;IAC3D,YAAY,GAAa,EAAE,QAAiB;QACxC,IAAI,GAAG,GAAG,yBAAyB,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,CAAA;QAC3D,IAAI,QAAQ,EAAE,CAAC;YACX,GAAG,IAAI,IAAI,GAAG,QAAQ,CAAA;QAC1B,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACJ;AARD,sDAQC;AAGD,SAAgB,sBAAsB,CAAC,GAAY;IAC/C,OAAO,GAAG,YAAY,KAAK,IAAI,CAAC,CAAE,GAAW,CAAC,yBAAyB,CAAA;AAC3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subsquid/util-internal-data-source",
|
|
3
|
-
"version": "0.0.1-portal-api.
|
|
3
|
+
"version": "0.0.1-portal-api.d0738f",
|
|
4
4
|
"description": "Definition of DataSource abstraction",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": "git@github.com:subsquid/squid.git",
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,8 @@ export interface BlockRef {
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export interface DataSourceStreamOptions {
|
|
12
|
-
|
|
12
|
+
after?: BlockRef
|
|
13
13
|
stopOnHead?: boolean
|
|
14
|
-
parentHash?: string
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
|
|
@@ -21,18 +20,15 @@ export interface BlockBatch<B> {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
|
|
24
|
-
export type DataSourceStream<B> = AsyncIterable<BlockBatch<B>>
|
|
25
|
-
|
|
26
|
-
|
|
27
23
|
export interface DataSource<B> {
|
|
28
24
|
getHead(): Promise<BlockRef | undefined>
|
|
29
25
|
|
|
30
26
|
getFinalizedHead(): Promise<BlockRef | undefined>
|
|
31
27
|
|
|
32
28
|
// FIXME: maybe it's better to pass it ias an option to `getStream`
|
|
33
|
-
getFinalizedStream(req: DataSourceStreamOptions):
|
|
29
|
+
getFinalizedStream(req: DataSourceStreamOptions): AsyncIterable<BlockBatch<B>>
|
|
34
30
|
|
|
35
|
-
getStream(req: DataSourceStreamOptions):
|
|
31
|
+
getStream(req: DataSourceStreamOptions): AsyncIterable<BlockBatch<B>>
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
|
|
@@ -40,13 +36,13 @@ export class ForkException extends Error {
|
|
|
40
36
|
readonly isSqdForkException = true
|
|
41
37
|
|
|
42
38
|
constructor(
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
blockNumber: number,
|
|
40
|
+
parentBlockHash: string,
|
|
45
41
|
public readonly previousBlocks: BlockRef[]
|
|
46
42
|
) {
|
|
47
43
|
assert(previousBlocks.length > 0)
|
|
48
44
|
let last = previousBlocks[previousBlocks.length - 1]
|
|
49
|
-
super(`expected ${
|
|
45
|
+
super(`expected ${blockNumber} to have parent ${last.number}#${parentBlockHash}, but got ${last.number}#${last.hash}`)
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
get name(): string {
|