@ckb-ccc/core 0.0.13-alpha.4 → 0.0.13-alpha.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ckb-ccc/core
2
2
 
3
+ ## 0.0.13-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6d62032`](https://github.com/ckb-ecofund/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): recordCells should not add usableCells
8
+
3
9
  ## 0.0.13-alpha.4
4
10
 
5
11
  ### Patch Changes
@@ -3,18 +3,18 @@ import { HexLike } from "../../hex/index.js";
3
3
  import { ClientCollectableSearchKeyLike } from "../clientTypes.advanced.js";
4
4
  import { ClientCache } from "./cache.js";
5
5
  export declare class ClientCacheMemory implements ClientCache {
6
- private readonly cachedTransactions;
7
6
  private readonly unusableOutPoints;
8
7
  private readonly usableCells;
8
+ private readonly knownTransactions;
9
9
  private readonly knownCells;
10
10
  markUsable(...cellLikes: (CellLike | CellLike[])[]): Promise<void>;
11
11
  markUnusable(...outPointLikes: (OutPointLike | OutPointLike[])[]): Promise<void>;
12
12
  markTransactions(...transactionLike: (TransactionLike | TransactionLike[])[]): Promise<void>;
13
+ findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
13
14
  isUnusable(outPointLike: OutPointLike): Promise<boolean>;
14
15
  recordTransactions(...transactions: (TransactionLike | TransactionLike[])[]): Promise<void>;
15
16
  getTransaction(txHashLike: HexLike): Promise<Transaction | undefined>;
16
17
  recordCells(...cells: (CellLike | CellLike[])[]): Promise<void>;
17
18
  getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
18
- findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
19
19
  }
20
20
  //# sourceMappingURL=memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory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AC,EAAE,GACvD,OAAO,CAAC,IAAI,CAAC;IAGV,cAAc,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAKrE,WAAW,CAAC,GAAG,KAAK,EAAE,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAG/D,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAIrE"}
@@ -3,9 +3,9 @@ import { hexFrom } from "../../hex/index.js";
3
3
  import { filterCell } from "./memory.advanced.js";
4
4
  export class ClientCacheMemory {
5
5
  constructor() {
6
- this.cachedTransactions = [];
7
6
  this.unusableOutPoints = [];
8
7
  this.usableCells = [];
8
+ this.knownTransactions = [];
9
9
  this.knownCells = [];
10
10
  }
11
11
  async markUsable(...cellLikes) {
@@ -44,30 +44,30 @@ export class ClientCacheMemory {
44
44
  })));
45
45
  }));
46
46
  }
47
+ async *findCells(keyLike) {
48
+ for (const cell of this.usableCells) {
49
+ if (!filterCell(keyLike, cell)) {
50
+ continue;
51
+ }
52
+ yield cell;
53
+ }
54
+ }
47
55
  async isUnusable(outPointLike) {
48
56
  const outPoint = OutPoint.from(outPointLike);
49
57
  return this.unusableOutPoints.find((o) => o.eq(outPoint)) !== undefined;
50
58
  }
51
59
  async recordTransactions(...transactions) {
52
- this.cachedTransactions.push(...transactions.flat().map(Transaction.from));
60
+ this.knownTransactions.push(...transactions.flat().map(Transaction.from));
53
61
  }
54
62
  async getTransaction(txHashLike) {
55
63
  const txHash = hexFrom(txHashLike);
56
- return this.cachedTransactions.find((tx) => tx.hash() === txHash);
64
+ return this.knownTransactions.find((tx) => tx.hash() === txHash);
57
65
  }
58
66
  async recordCells(...cells) {
59
- this.usableCells.push(...cells.flat().map(Cell.from));
67
+ this.knownCells.push(...cells.flat().map(Cell.from));
60
68
  }
61
69
  async getCell(outPointLike) {
62
70
  const outPoint = OutPoint.from(outPointLike);
63
- return this.usableCells.find((cell) => cell.outPoint.eq(outPoint));
64
- }
65
- async *findCells(keyLike) {
66
- for (const cell of this.usableCells) {
67
- if (!filterCell(keyLike, cell)) {
68
- continue;
69
- }
70
- yield cell;
71
- }
71
+ return this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
72
72
  }
73
73
  }
@@ -3,18 +3,18 @@ import { HexLike } from "../../hex/index.js";
3
3
  import { ClientCollectableSearchKeyLike } from "../clientTypes.advanced.js";
4
4
  import { ClientCache } from "./cache.js";
5
5
  export declare class ClientCacheMemory implements ClientCache {
6
- private readonly cachedTransactions;
7
6
  private readonly unusableOutPoints;
8
7
  private readonly usableCells;
8
+ private readonly knownTransactions;
9
9
  private readonly knownCells;
10
10
  markUsable(...cellLikes: (CellLike | CellLike[])[]): Promise<void>;
11
11
  markUnusable(...outPointLikes: (OutPointLike | OutPointLike[])[]): Promise<void>;
12
12
  markTransactions(...transactionLike: (TransactionLike | TransactionLike[])[]): Promise<void>;
13
+ findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
13
14
  isUnusable(outPointLike: OutPointLike): Promise<boolean>;
14
15
  recordTransactions(...transactions: (TransactionLike | TransactionLike[])[]): Promise<void>;
15
16
  getTransaction(txHashLike: HexLike): Promise<Transaction | undefined>;
16
17
  recordCells(...cells: (CellLike | CellLike[])[]): Promise<void>;
17
18
  getCell(outPointLike: OutPointLike): Promise<Cell | undefined>;
18
- findCells(keyLike: ClientCollectableSearchKeyLike): AsyncGenerator<Cell>;
19
19
  }
20
20
  //# sourceMappingURL=memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/client/cache/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,QAAQ,EAER,YAAY,EACZ,WAAW,EACX,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAW,MAAM,oBAAoB,CAAC;AACt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AO,CAAC,IAAI,CAAC;IAG/D,OAAO,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;CAIrE"}
@@ -6,9 +6,9 @@ const index_js_2 = require("../../hex/index.js");
6
6
  const memory_advanced_js_1 = require("./memory.advanced.js");
7
7
  class ClientCacheMemory {
8
8
  constructor() {
9
- this.cachedTransactions = [];
10
9
  this.unusableOutPoints = [];
11
10
  this.usableCells = [];
11
+ this.knownTransactions = [];
12
12
  this.knownCells = [];
13
13
  }
14
14
  async markUsable(...cellLikes) {
@@ -47,31 +47,31 @@ class ClientCacheMemory {
47
47
  })));
48
48
  }));
49
49
  }
50
+ async *findCells(keyLike) {
51
+ for (const cell of this.usableCells) {
52
+ if (!(0, memory_advanced_js_1.filterCell)(keyLike, cell)) {
53
+ continue;
54
+ }
55
+ yield cell;
56
+ }
57
+ }
50
58
  async isUnusable(outPointLike) {
51
59
  const outPoint = index_js_1.OutPoint.from(outPointLike);
52
60
  return this.unusableOutPoints.find((o) => o.eq(outPoint)) !== undefined;
53
61
  }
54
62
  async recordTransactions(...transactions) {
55
- this.cachedTransactions.push(...transactions.flat().map(index_js_1.Transaction.from));
63
+ this.knownTransactions.push(...transactions.flat().map(index_js_1.Transaction.from));
56
64
  }
57
65
  async getTransaction(txHashLike) {
58
66
  const txHash = (0, index_js_2.hexFrom)(txHashLike);
59
- return this.cachedTransactions.find((tx) => tx.hash() === txHash);
67
+ return this.knownTransactions.find((tx) => tx.hash() === txHash);
60
68
  }
61
69
  async recordCells(...cells) {
62
- this.usableCells.push(...cells.flat().map(index_js_1.Cell.from));
70
+ this.knownCells.push(...cells.flat().map(index_js_1.Cell.from));
63
71
  }
64
72
  async getCell(outPointLike) {
65
73
  const outPoint = index_js_1.OutPoint.from(outPointLike);
66
- return this.usableCells.find((cell) => cell.outPoint.eq(outPoint));
67
- }
68
- async *findCells(keyLike) {
69
- for (const cell of this.usableCells) {
70
- if (!(0, memory_advanced_js_1.filterCell)(keyLike, cell)) {
71
- continue;
72
- }
73
- yield cell;
74
- }
74
+ return this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
75
75
  }
76
76
  }
77
77
  exports.ClientCacheMemory = ClientCacheMemory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckb-ccc/core",
3
- "version": "0.0.13-alpha.4",
3
+ "version": "0.0.13-alpha.5",
4
4
  "description": "Core of CCC - CKBer's Codebase",
5
5
  "author": "Hanssen0 <hanssen0@hanssen0.com>",
6
6
  "license": "MIT",
@@ -12,9 +12,9 @@ import { ClientCache } from "./cache.js";
12
12
  import { filterCell } from "./memory.advanced.js";
13
13
 
14
14
  export class ClientCacheMemory implements ClientCache {
15
- private readonly cachedTransactions: Transaction[] = [];
16
15
  private readonly unusableOutPoints: OutPoint[] = [];
17
16
  private readonly usableCells: Cell[] = [];
17
+ private readonly knownTransactions: Transaction[] = [];
18
18
  private readonly knownCells: Cell[] = [];
19
19
 
20
20
  async markUsable(...cellLikes: (CellLike | CellLike[])[]): Promise<void> {
@@ -73,6 +73,18 @@ export class ClientCacheMemory implements ClientCache {
73
73
  );
74
74
  }
75
75
 
76
+ async *findCells(
77
+ keyLike: ClientCollectableSearchKeyLike,
78
+ ): AsyncGenerator<Cell> {
79
+ for (const cell of this.usableCells) {
80
+ if (!filterCell(keyLike, cell)) {
81
+ continue;
82
+ }
83
+
84
+ yield cell;
85
+ }
86
+ }
87
+
76
88
  async isUnusable(outPointLike: OutPointLike): Promise<boolean> {
77
89
  const outPoint = OutPoint.from(outPointLike);
78
90
  return this.unusableOutPoints.find((o) => o.eq(outPoint)) !== undefined;
@@ -81,30 +93,18 @@ export class ClientCacheMemory implements ClientCache {
81
93
  async recordTransactions(
82
94
  ...transactions: (TransactionLike | TransactionLike[])[]
83
95
  ): Promise<void> {
84
- this.cachedTransactions.push(...transactions.flat().map(Transaction.from));
96
+ this.knownTransactions.push(...transactions.flat().map(Transaction.from));
85
97
  }
86
98
  async getTransaction(txHashLike: HexLike): Promise<Transaction | undefined> {
87
99
  const txHash = hexFrom(txHashLike);
88
- return this.cachedTransactions.find((tx) => tx.hash() === txHash);
100
+ return this.knownTransactions.find((tx) => tx.hash() === txHash);
89
101
  }
90
102
 
91
103
  async recordCells(...cells: (CellLike | CellLike[])[]): Promise<void> {
92
- this.usableCells.push(...cells.flat().map(Cell.from));
104
+ this.knownCells.push(...cells.flat().map(Cell.from));
93
105
  }
94
106
  async getCell(outPointLike: OutPointLike): Promise<Cell | undefined> {
95
107
  const outPoint = OutPoint.from(outPointLike);
96
- return this.usableCells.find((cell) => cell.outPoint.eq(outPoint));
97
- }
98
-
99
- async *findCells(
100
- keyLike: ClientCollectableSearchKeyLike,
101
- ): AsyncGenerator<Cell> {
102
- for (const cell of this.usableCells) {
103
- if (!filterCell(keyLike, cell)) {
104
- continue;
105
- }
106
-
107
- yield cell;
108
- }
108
+ return this.knownCells.find((cell) => cell.outPoint.eq(outPoint));
109
109
  }
110
110
  }