-
Notifications
You must be signed in to change notification settings - Fork 0
/
findDataForBlock.js
executable file
·79 lines (75 loc) · 2.3 KB
/
findDataForBlock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const BloomFilter = require('bloom-filter');
const Validator = require('../../utils/Validator');
const argsSchema = require('../schemas/getSpvData');
const validator = new Validator(argsSchema);
/**
* @param spvService
* @return {findSpvData}
*/
const findDataForBlockFactory = (spvService) => {
/**
* Layer 1 endpoint
* finds relevant data for addresses encoded in a bloom filter in a specific block
* @typedef findDataForBlock
* @param args - command arguments
* @param {string} args.filter
* @return {object}
*/
async function findDataForBlock(args) {
validator.validate(args);
const filter = new BloomFilter(args.filter);
return spvService.findDataForBlock(filter, args.blockHash);
}
return findDataForBlock;
};
/* eslint-disable max-len */
/**
* @swagger
* /findDataForBlock:
* post:
* operationId: findDataForBlock
* deprecated: false
* summary: findDataForBlock
* description: Finds relevant data in a specific block for addresses encoded in a bloom filter
* tags:
* - L1
* responses:
* 200:
* description: Successful response. An object containing block headers.
* requestBody:
* content:
* application/json:
* schema:
* type: object
* required:
* - method
* - id
* - jsonrpc
* - params
* properties:
* method:
* type: string
* default: findDataForBlock
* description: Method name
* id:
* type: integer
* default: 1
* format: int32
* description: Request ID
* jsonrpc:
* type: string
* default: '2.0'
* description: JSON-RPC Version (2.0)
* params:
* title: Parameters
* type: object
* required:
* - filter
* properties:
* filter:
* type: string
* default: ''
* description: A bloom filter
*/
/* eslint-enable max-len */
module.exports = findDataForBlockFactory;