@xyo-network/origin-block-repository
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -6,3 +6,3 @@ /// <reference types="node" /> | ||
import { IXyoHash } from '@xyo-network/hashing'; | ||
import { IXyoTypeSerializer } from '@xyo-network/serialization'; | ||
import { IXyoSerializationService } from '@xyo-network/serialization'; | ||
/** | ||
@@ -14,4 +14,3 @@ * An XyoOriginChainNavigator exposes an api for managing | ||
private readonly originBlocksStorageProvider; | ||
private readonly boundWitnessSerializer; | ||
private readonly hashSerializer; | ||
private readonly serializationService; | ||
/** | ||
@@ -22,3 +21,3 @@ * Creates an instance of a XyoOriginChainNavigator | ||
*/ | ||
constructor(originBlocksStorageProvider: IXyoStorageProvider, boundWitnessSerializer: IXyoTypeSerializer<IXyoBoundWitness>, hashSerializer: IXyoTypeSerializer<IXyoHash>); | ||
constructor(originBlocksStorageProvider: IXyoStorageProvider, serializationService: IXyoSerializationService); | ||
/** | ||
@@ -25,0 +24,0 @@ * Removes an origin block from storage if it exists |
@@ -8,3 +8,3 @@ "use strict"; | ||
* @Last modified by: ryanxyo | ||
* @Last modified time: Wednesday, 21st November 2018 4:01:15 pm | ||
* @Last modified time: Tuesday, 11th December 2018 9:59:15 am | ||
* @License: All Rights Reserved | ||
@@ -22,3 +22,2 @@ * @Copyright: Copyright XY | The Findables Company | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const storage_1 = require("@xyo-network/storage"); | ||
/** | ||
@@ -34,6 +33,5 @@ * An XyoOriginChainNavigator exposes an api for managing | ||
*/ | ||
constructor(originBlocksStorageProvider, boundWitnessSerializer, hashSerializer) { | ||
constructor(originBlocksStorageProvider, serializationService) { | ||
this.originBlocksStorageProvider = originBlocksStorageProvider; | ||
this.boundWitnessSerializer = boundWitnessSerializer; | ||
this.hashSerializer = hashSerializer; | ||
this.serializationService = serializationService; | ||
} | ||
@@ -65,3 +63,5 @@ /** | ||
const result = yield this.originBlocksStorageProvider.iterate({ limit, offsetKey: offsetHash }); | ||
const blocks = result.items.map(keyPair => this.boundWitnessSerializer.deserialize(keyPair.value)); | ||
const blocks = result.items.map((keyPair) => { | ||
return this.serializationService.deserialize(keyPair.value).hydrate(); | ||
}); | ||
return { | ||
@@ -109,5 +109,5 @@ list: blocks, | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const blockDataValue = this.boundWitnessSerializer.serialize(originBlock, 'buffer'); | ||
const blockHashValue = this.hashSerializer.serialize(blockHash, 'buffer'); | ||
yield this.originBlocksStorageProvider.write(blockHashValue, blockDataValue, storage_1.XyoStoragePriority.PRIORITY_MED, true, 60000); | ||
const blockDataValue = originBlock.serialize(); | ||
const blockHashValue = blockHash.serialize(); | ||
yield this.originBlocksStorageProvider.write(blockHashValue, blockDataValue); | ||
}); | ||
@@ -118,7 +118,8 @@ } | ||
try { | ||
const result = yield this.originBlocksStorageProvider.read(hash, 60000); | ||
const result = yield this.originBlocksStorageProvider.read(hash); | ||
if (!result) { | ||
return undefined; | ||
} | ||
return this.boundWitnessSerializer.deserialize(result); | ||
throw new Error(`TODO`); | ||
// return this.serializationService.deserialize<IXyoBoundWitness>(result) | ||
} | ||
@@ -125,0 +126,0 @@ catch (err) { |
{ | ||
"name": "@xyo-network/origin-block-repository", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "An abstraction over a collection of origin blocks", | ||
@@ -10,6 +10,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@xyo-network/bound-witness": "^0.2.1", | ||
"@xyo-network/hashing": "^0.2.1", | ||
"@xyo-network/serialization": "^0.2.1", | ||
"@xyo-network/storage": "^0.2.1" | ||
"@xyo-network/bound-witness": "^0.3.0", | ||
"@xyo-network/hashing": "^0.3.0", | ||
"@xyo-network/serialization": "^0.3.0", | ||
"@xyo-network/storage": "^0.3.0" | ||
}, | ||
@@ -25,3 +25,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "0635d162b742fbb5ee4f09d4e3faf5149b43eaf0" | ||
"gitHead": "55319bda08512a2701fb6494ad2e2526791e6bb7" | ||
} |
@@ -7,3 +7,3 @@ /* | ||
* @Last modified by: ryanxyo | ||
* @Last modified time: Wednesday, 21st November 2018 4:01:15 pm | ||
* @Last modified time: Tuesday, 11th December 2018 9:59:15 am | ||
* @License: All Rights Reserved | ||
@@ -13,7 +13,7 @@ * @Copyright: Copyright XY | The Findables Company | ||
import { XyoStoragePriority, IXyoStorageProvider, IXyoIterableStorageProvider } from '@xyo-network/storage' | ||
import { IXyoStorageProvider, IXyoIterableStorageProvider } from '@xyo-network/storage' | ||
import { IXyoBoundWitness } from '@xyo-network/bound-witness' | ||
import { IXyoOriginBlockRepository, IOriginBlockQueryResult } from './@types' | ||
import { IXyoHash } from '@xyo-network/hashing' | ||
import { IXyoTypeSerializer } from '@xyo-network/serialization' | ||
import { IXyoSerializationService } from '@xyo-network/serialization' | ||
@@ -35,4 +35,3 @@ /** | ||
private readonly originBlocksStorageProvider: IXyoStorageProvider, | ||
private readonly boundWitnessSerializer: IXyoTypeSerializer<IXyoBoundWitness>, | ||
private readonly hashSerializer: IXyoTypeSerializer<IXyoHash>, | ||
private readonly serializationService: IXyoSerializationService | ||
) {} | ||
@@ -65,3 +64,5 @@ | ||
const result = await this.originBlocksStorageProvider.iterate({ limit, offsetKey: offsetHash }) | ||
const blocks = result.items.map(keyPair => this.boundWitnessSerializer.deserialize(keyPair.value)) | ||
const blocks = result.items.map((keyPair) => { | ||
return this.serializationService.deserialize(keyPair.value).hydrate<IXyoBoundWitness>() | ||
}) | ||
@@ -116,12 +117,6 @@ return { | ||
public async addOriginBlock(blockHash: IXyoHash, originBlock: IXyoBoundWitness): Promise<void> { | ||
const blockDataValue = this.boundWitnessSerializer.serialize(originBlock, 'buffer') as Buffer | ||
const blockHashValue = this.hashSerializer.serialize(blockHash, 'buffer') as Buffer | ||
const blockDataValue = originBlock.serialize() | ||
const blockHashValue = blockHash.serialize() | ||
await this.originBlocksStorageProvider.write( | ||
blockHashValue, | ||
blockDataValue, | ||
XyoStoragePriority.PRIORITY_MED, | ||
true, | ||
60000 | ||
) | ||
await this.originBlocksStorageProvider.write(blockHashValue, blockDataValue) | ||
} | ||
@@ -131,3 +126,3 @@ | ||
try { | ||
const result = await this.originBlocksStorageProvider.read(hash, 60000) | ||
const result = await this.originBlocksStorageProvider.read(hash) | ||
if (!result) { | ||
@@ -137,3 +132,4 @@ return undefined | ||
return this.boundWitnessSerializer.deserialize(result) | ||
throw new Error(`TODO`) | ||
// return this.serializationService.deserialize<IXyoBoundWitness>(result) | ||
} catch (err) { | ||
@@ -140,0 +136,0 @@ return undefined |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23327
450
+ Added@xyo-network/base@0.3.1(transitive)
+ Added@xyo-network/bound-witness@0.3.1(transitive)
+ Added@xyo-network/buffer-utils@0.3.1(transitive)
+ Added@xyo-network/errors@0.3.1(transitive)
+ Added@xyo-network/hashing@0.3.1(transitive)
+ Added@xyo-network/serialization@0.3.1(transitive)
+ Added@xyo-network/serialization-schema@0.3.1(transitive)
+ Added@xyo-network/signing@0.3.1(transitive)
+ Added@xyo-network/storage@0.3.1(transitive)
- Removed@xyo-network/base@0.2.1(transitive)
- Removed@xyo-network/bound-witness@0.2.1(transitive)
- Removed@xyo-network/errors@0.2.1(transitive)
- Removed@xyo-network/hashing@0.2.1(transitive)
- Removed@xyo-network/serialization@0.2.1(transitive)
- Removed@xyo-network/serialization-schema@0.2.1(transitive)
- Removed@xyo-network/signing@0.2.1(transitive)
- Removed@xyo-network/storage@0.2.1(transitive)
Updated@xyo-network/hashing@^0.3.0
Updated@xyo-network/storage@^0.3.0