Skip to content

Commit

Permalink
docs: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nugaon committed Aug 21, 2023
1 parent 327c39b commit 9858cb2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 150 deletions.
56 changes: 23 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Creates a new Feed reader

| Name | Type | Description |
| ---- | ---- | ----------- |
| `topic` | `Topic | Uint8Array | string` | The feeds topic |
| `owner` | `EthAddress | Uint8Array | string` | Address of signer |
| `topic` | `Topic \| Uint8Array \| string` | The feeds topic |
| `owner` | `EthAddress \| Uint8Array \| string` | Address of signer |
| `options` | `any ` | Options |

### Returns
Expand Down Expand Up @@ -83,13 +83,13 @@ A FeedChunk<Index> object

## getUpdate

Gets a chunk update from a index
Gets the chunk update the given index

### Arguments

| Name | Type | Description |
| ---- | ---- | ----------- |
| `index` | `Index ` | Options |
| `index` | `Index` | Options |


### Returns
Expand All @@ -110,7 +110,7 @@ Gets a set of chunks

### Returns

A FeedChunk<Indices> object
A FeedChunk<Index>[] array


## Feed Writer
Expand Down Expand Up @@ -192,6 +192,14 @@ A Reference object

## Streaming feeds

### Arguments

| Name | Type | Description |
| ---- | ---- | ----------- |
| `bee` | `Bee` | Bee instance |
| `initialTime` | `number ` | initial time of streaming feed |
| `updatePeriod` | `number ` | feed update frequency |

## Feed Reader

## makeFeedR
Expand Down Expand Up @@ -222,7 +230,9 @@ const myIdentity = {
address: '8d3766440f0d7b949a5e32995d09619a7f86e632' as HexString,
}
const topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic
const streamingFeed = new StreamingFeed(new Bee('http://localhost:1633'))
const initialTime = Date.now()
const period = 5000 // ms
const streamingFeed = new StreamingFeed(new Bee('http://localhost:1633'), initialTime, period)

// Feed Reader
const emptyTopic = '1200000000000000000000000000000000000000000000000000000000000001' as Topic
Expand All @@ -238,8 +248,6 @@ Gets an index from an arbitrary time
| Name | Type | Description |
| ---- | ---- | ----------- |
| `lookupTime` | `number ` | Time position to lookup |
| `initialTime` | `number ` | feed chunk timestamp for index at 0 |
| `updatePeriod` | `number ` | feed update frequency |

### Returns

Expand All @@ -254,8 +262,6 @@ Gets a chunk update from an arbitrary time, if lookup time is empty, it will ret

| Name | Type | Description |
| ---- | ---- | ----------- |
| `initialTime` | `number ` | feed chunk timestamp for index at 0 |
| `updatePeriod` | `number ` | feed update frequency |
| `lookupTime` | `number ` | Time position to lookup (optional) |


Expand All @@ -268,17 +274,10 @@ A StreamingFeedChunk<Index> object

Gets a set of chunks from an arbitray time

### Arguments

| Name | Type | Description |
| ---- | ---- | ----------- |
| `initialTime` | `number ` | feed chunk timestamp for index at 0 |
| `updatePeriod` | `number ` | feed update frequency |


### Returns

A StreamingFeedChunk<Indices> object
A StreamingFeedChunk array


## Feed Writer
Expand Down Expand Up @@ -314,7 +313,9 @@ const myIdentity = {
}
const signer = makePrivateKeySigner(hexToBytes(myIdentity.privateKey) as Bytes<32>)
const topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic
const streamingFeed = new StreamingFeed(new Bee('http://localhost:1633'))
const initialTime = Date.now()
const period = 5000 // ms
const streamingFeed = new StreamingFeed(new Bee('http://localhost:1633'), initialTime, period)
// Feed Reader/Writer
const feedRw = streamingFeed.makeFeedRW(topic, signer)
Expand All @@ -330,11 +331,6 @@ Appends a new chunk to a feed, if the lookup time is empty, it will be added to
| ---- | ---- | ----------- |
| `postageBatchId` | `string | BatchId ` | postage batch id |
| `reference` | `Reference` | reference |
| `initialTime` | `number ` | feed chunk timestamp for index at 0 |
| `updatePeriod` | `number ` | feed update frequency |
| `lookupTime` | `number ` | Time position to lookup (optional) |



### Returns

Expand All @@ -350,15 +346,9 @@ Sets a chunk to a feed at an index number
| Name | Type | Description |
| ---- | ---- | ----------- |
| `index` | `number` | index |
| `postageBatchId` | `string | BatchId ` | postage batch id |
| `reference` | `Reference` | reference |
| `initialTime` | `number ` | feed chunk timestamp for index at 0 |
| `updatePeriod` | `number ` | feed update frequency |
| `lookupTime` | `number ` | Time position to lookup (optional) |


| `postageBatchId` | `string \| BatchId` | postage batch id |
| `reference` | `Reference` | wrapped chunk reference |

### Returns

A Reference object

A Reference of the Feed chunk
18 changes: 9 additions & 9 deletions src/sequential-feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SequentialFeed implements SwarmFeed<number> {

/**
* Downloads a chunk by index number
* @param index index number
* @param index index number of the feed chunk
* @returns A feed chunk
*/
const getUpdate = async (index: number): Promise<FeedChunk> => {
Expand All @@ -81,9 +81,9 @@ export class SequentialFeed implements SwarmFeed<number> {
}

/**
* Download all chunk by indices
* @param indices an array of index numbers
* @returns An array of chunks
* Download all chunks by indices
* @param indices an array of indices
* @returns An array of feed chunks
*/
const getUpdates = async (indices: number[]): Promise<FeedChunk[]> => {
const promises: Promise<SingleOwnerChunk>[] = []
Expand Down Expand Up @@ -126,8 +126,8 @@ export class SequentialFeed implements SwarmFeed<number> {
* Sets the upload chunk to update
* @param index the chunk index to update
* @param postageBatchId swarm postage batch id
* @param reference chunk reference
* @returns a chunk reference
* @param reference wrapped chunk reference
* @returns a SOC reference
*/
const setUpdate = async (
index: number,
Expand All @@ -146,8 +146,8 @@ export class SequentialFeed implements SwarmFeed<number> {
/**
* Sets the next upload chunk
* @param postageBatchId swarm postage batch id
* @param reference chunk reference
* @returns a chunk reference
* @param reference wrapped chunk reference
* @returns a SOC reference
*/
const setLastUpdate = async (postageBatchId: string | BatchId, reference: Reference): Promise<Reference> => {
let index: number
Expand All @@ -172,7 +172,7 @@ export class SequentialFeed implements SwarmFeed<number> {
* Get Single Owner Chunk identifier
* @param topic a swarm topic, bytes 32 length
* @param index the chunk index
* @returns a bytes 32
* @returns 32 bytes
*/
public getIdentifier(topic: Utils.Bytes.Bytes<32>, index: number): Utils.Bytes.Bytes<32> {
const indexBytes = writeUint64BigEndian(index)
Expand Down
108 changes: 0 additions & 108 deletions src/streaming.ts

This file was deleted.

0 comments on commit 9858cb2

Please sign in to comment.