@@ -3,7 +3,7 @@ import { CqlWebSocket } from '../client/socket'
3
3
import { RPCObject , constructRPCObj } from '../client/rpc'
4
4
5
5
export interface BpInterface {
6
- // getProtocolVersion(): Promise<any >
6
+ getProtocolVersion ( ) : Promise < string >
7
7
// getRunningStatus(): Promise<any>
8
8
getBlockList ( from : number , to : number ) : Promise < Array < object > >
9
9
// getBlockListByTimeRange(): Promise<any>
@@ -14,6 +14,7 @@ export interface BpInterface {
14
14
}
15
15
16
16
export enum BpMethodType {
17
+ GET_PROTOCOL_VERSION = 'bp_getProtocolVersion' ,
17
18
GET_BLOCK_LIST = 'bp_getBlockList'
18
19
}
19
20
@@ -29,14 +30,28 @@ export default class Bp implements BpInterface {
29
30
this . debug = debugFactory ( 'cql:bp' )
30
31
}
31
32
32
- public getBlockList ( from : number , to : number ) : Promise < Array < object > > {
33
+ public getProtocolVersion ( ) : Promise < string > {
34
+ let req : RPCObject = constructRPCObj ( BpMethodType . GET_PROTOCOL_VERSION )
35
+ this . debug ( 'Send getProtocolVersion' )
36
+ return new Promise ( resolve => {
37
+ this . client . send ( req , res => {
38
+ this . debug ( 'Got getProtocolVersion response' , res )
39
+ resolve ( res . result )
40
+ } )
41
+ } )
42
+ }
43
+
44
+ public getBlockList (
45
+ from : number ,
46
+ to : number
47
+ ) : Promise < Array < object > > {
33
48
let params = [ from , to ]
34
49
let req : RPCObject = constructRPCObj ( BpMethodType . GET_BLOCK_LIST , params )
35
50
36
- this . debug ( 'getBlockList of ' , req )
51
+ this . debug ( 'Send getBlockList of ' , req )
37
52
return new Promise ( ( resolve ) => {
38
53
this . client . send ( req , ( res ) => {
39
- this . debug ( 'get response' , res )
54
+ this . debug ( 'Got getBlockList response' , res )
40
55
if ( res . id === req . id ) {
41
56
resolve ( res . result )
42
57
}
0 commit comments