SkipchainRPC provides basic tools to interact with a skipchain with a given roster

TODO:

- make SkipchainRPC with only static methods
- add Skipchain class that represents one single skipchain

### Hierarchy

- SkipchainRPC

## Index

### Constructors

- constructor

### Properties

- conn
- roster
- serviceName

### Methods

- addBlock
- createSkipchain
- getAllSkipChainIDs
- getLatestBlock
- getSkipBlock
- getSkipBlockByIndex
- getUpdateChain
- verifyChain
- getLeader

## Constructors

### constructor

- new SkipchainRPC(nodes: Roster | IConnection | RosterWSConnection): SkipchainRPC

- - Defined in src/skipchain/skipchain-rpc.ts:42

  #### Parameters

  - ##### nodes: Roster | IConnection | RosterWSConnection

  #### Returns SkipchainRPC

## Properties

### Private conn

conn: RosterWSConnection | IConnection | undefined

- Defined in src/skipchain/skipchain-rpc.ts:42

### Private roster

roster: Roster

- Defined in src/skipchain/skipchain-rpc.ts:41

### Static serviceName

serviceName: string = "Skipchain"

- Defined in src/skipchain/skipchain-rpc.ts:30

## Methods

### addBlock

- addBlock(gid: Buffer, msg: Buffer): Promise<StoreSkipBlockReply>

- - Defined in src/skipchain/skipchain-rpc.ts:82

  Add a new block to a given skipchain

  throws

    an error if the request is not successful

  #### Parameters

  - ##### gid: Buffer

    the genesis ID of the skipchain

  - ##### msg: Buffer

    the data to include in the block

  #### Returns Promise<StoreSkipBlockReply>

### createSkipchain

- createSkipchain(baseHeight?: number, maxHeight?: number): Promise<StoreSkipBlockReply>

- - Defined in src/skipchain/skipchain-rpc.ts:62

  Create a skipchain with a base and a max height

  #### Parameters

  - ##### Default value baseHeight: number = 4

    base height of the skipchain

  - ##### Default value maxHeight: number = 32

    maximum height of the skipchain

  #### Returns Promise<StoreSkipBlockReply>

  a promise that resolves with the genesis block

### getAllSkipChainIDs

- getAllSkipChainIDs(): Promise<Buffer[]>

- - Defined in src/skipchain/skipchain-rpc.ts:135

  Get the list of known skipchains

  #### Returns Promise<Buffer[]>

  a promise that resolves with the list of skipchain IDs

### getLatestBlock

- getLatestBlock(latestID: Buffer, verify?: boolean, acceptProxy?: boolean): Promise<SkipBlock>

- - Defined in src/skipchain/skipchain-rpc.ts:236

  Get the latest known block of the skipchain. It will follow the forward links as much as possible and it is resistant to roster changes.

  #### Parameters

  - ##### latestID: Buffer

    the current latest block

  - ##### Default value verify: boolean = true

    Verify the integrity of the chain

  - ##### Default value acceptProxy: boolean = false

  #### Returns Promise<SkipBlock>

  a promise that resolves with the block, or reject with an error

### getSkipBlock

- getSkipBlock(bid: Buffer): Promise<SkipBlock>

- - Defined in src/skipchain/skipchain-rpc.ts:101

  Get the block with the given ID

  #### Parameters

  - ##### bid: Buffer

    block ID being the hash

  #### Returns Promise<SkipBlock>

  a promise that resolves with the block

### getSkipBlockByIndex

- getSkipBlockByIndex(genesis: Buffer, index: number): Promise<GetSingleBlockByIndexReply>

- - Defined in src/skipchain/skipchain-rpc.ts:119

  Get the block by its index and the genesis block ID

  #### Parameters

  - ##### genesis: Buffer

    Genesis block ID

  - ##### index: number

    Index of the block

  #### Returns Promise<GetSingleBlockByIndexReply>

  a promise that resolves with the block, or reject with an error

### getUpdateChain

- getUpdateChain(latestID: Buffer, verify?: boolean, acceptProxy?: boolean, maxHeight?: number): Promise<SkipBlock[]>

- - Defined in src/skipchain/skipchain-rpc.ts:154

  Get the shortest path to the more recent block starting from latestID. As the initial roster can change during the skipchain, this method tries hard to get the complete update, even if the roster changes.

  #### Parameters

  - ##### latestID: Buffer

    ID of the block

  - ##### Default value verify: boolean = true

    Verify the integrity of the chain when true

  - ##### Default value acceptProxy: boolean = false

    if another node can reply even if its not in the roster

  - ##### Default value maxHeight: number = 0

    What maximal height to jump. 0: as high as possible, 1: only direct links

  #### Returns Promise<SkipBlock[]>

  a promise that resolves with the list of blocks

### verifyChain

- verifyChain(blocks: SkipBlock[], firstID?: Buffer): Error

- - Defined in src/skipchain/skipchain-rpc.ts:250

  Check the given chain of blocks to insure the integrity of the chain by following the forward links and verifying the signatures

  #### Parameters

  - ##### blocks: SkipBlock[]

    the chain to check

  - ##### Optional firstID: Buffer

    optional parameter to check the first block identity

  #### Returns Error

  null for a correct chain or a detailed error otherwise

### Static Private getLeader

- getLeader(roster: Roster): WebSocketConnection

- - Defined in src/skipchain/skipchain-rpc.ts:38

  Create a leader connection. As the roster can change over the course of a skipchain, this the leader is not always the same.

  #### Parameters

  - ##### roster: Roster

    list of nodes, the first one is taken as the leader

  #### Returns WebSocketConnection

Generated using TypeDoc