@@ -19,20 +19,24 @@ import { combineLatest, Observable } from 'rxjs';
1919import { map } from 'rxjs/operators' ;
2020import { BlockRepository } from '../infrastructure/BlockRepository' ;
2121import { ReceiptRepository } from '../infrastructure/ReceiptRepository' ;
22+ import { RepositoryFactory } from '../infrastructure/RepositoryFactory' ;
2223import { MerklePathItem } from '../model/blockchain/MerklePathItem' ;
2324import { UInt64 } from '../model/UInt64' ;
2425
2526/**
2627 * Transaction Service
2728 */
2829export class BlockService {
30+ private readonly blockRepository : BlockRepository ;
31+ private readonly receiptRepository : ReceiptRepository ;
2932
3033 /**
3134 * Constructor
32- * @param blockRepository
33- * @param receiptRepository
35+ * @param repositoryFactory
3436 */
35- constructor ( private readonly blockRepository : BlockRepository , private readonly receiptRepository : ReceiptRepository ) {
37+ constructor ( public readonly repositoryFactory : RepositoryFactory ) {
38+ this . blockRepository = repositoryFactory . createBlockRepository ( ) ;
39+ this . receiptRepository = repositoryFactory . createReceiptRepository ( ) ;
3640 }
3741
3842 /**
@@ -49,11 +53,11 @@ export class BlockService {
4953 }
5054
5155 /**
52- * Validate receipt hash in block
53- * @param leaf receipt hash
56+ * Validate statement hash in block
57+ * @param leaf statement hash
5458 * @param height block height
5559 */
56- public validateReceiptInBlock ( leaf : string , height : UInt64 ) : Observable < boolean > {
60+ public validateStatementInBlock ( leaf : string , height : UInt64 ) : Observable < boolean > {
5761 const rootHashObservable = this . blockRepository . getBlockByHeight ( height ) ;
5862 const merklePathItemObservable = this . receiptRepository . getMerkleReceipts ( height , leaf ) ;
5963 return combineLatest ( rootHashObservable , merklePathItemObservable ) . pipe (
0 commit comments