Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add getHead & newHead
  • Loading branch information
jacogr committed Apr 13, 2018
commit 6ec026c54186b0ec6ffa5766a31f479996fb3797
20 changes: 20 additions & 0 deletions packages/api-jsonrpc/src/chain/getHead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow

import type { InterfaceMethodDefinition } from '../types';

/**
@name getHead
@signature chain_getHead (): HeaderHash
@summary Retrieves the best headerHash.
@description
Return the block hash for the lastest/best.
*/
module.exports = ({
inputs: [],
output: {
type: 'HeaderHash'
}
}: InterfaceMethodDefinition);
6 changes: 5 additions & 1 deletion packages/api-jsonrpc/src/chain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@

import type { InterfaceDefinition } from '../types';

const getHead = require('./getHead');
const getHeader = require('./getHeader');
const newHead = require('./newHead');

/**
@summary Methods to retrieve chain data.
*/
module.exports = ({
methods: {
getHeader
getHead,
getHeader,
newHead
}
}: InterfaceDefinition);
21 changes: 21 additions & 0 deletions packages/api-jsonrpc/src/chain/newHead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow

import type { InterfaceMethodDefinition } from '../types';

/**
@name getHead
@signature chain_newHead (): HeaderHash
@summary Retrieves the best headerHash via subscription.
@description
Return the block hash for the lastest/best.
*/
module.exports = ({
isSubscription: true,
inputs: [],
output: {
type: 'HeaderHash'
}
}: InterfaceMethodDefinition);
8 changes: 7 additions & 1 deletion packages/api-jsonrpc/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ export type InterfaceOutputType = {
type: FormatOutputType
};

export type InterfaceMethodDefinition$Subscribe = {
subscribe: string,
unsubscribe: string
}

export type InterfaceMethodDefinition = {
deprecated?: boolean,
isDeprecated?: boolean,
isSubscription?: boolean,
inputs: Array<InterfaceInputType>,
output: InterfaceOutputType
};
Expand Down