Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create @helia/block-brokers package (#341) #342

Merged
merged 11 commits into from
Jan 8, 2024
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"packages/helia":"2.1.0","packages/interface":"2.1.0","packages/interop":"1.1.0"}
{"packages/block-brokers":"0.9.0", "packages/helia":"2.1.0","packages/interface":"2.1.0","packages/interop":"1.1.0"}
1 change: 1 addition & 0 deletions .release-please.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"plugins": ["node-workspace"],
"packages": {
"packages/block-brokers": {},
"packages/helia": {},
"packages/interface": {},
"packages/interop": {}
Expand Down
Empty file.
4 changes: 4 additions & 0 deletions packages/block-brokers/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.

MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
5 changes: 5 additions & 0 deletions packages/block-brokers/LICENSE-APACHE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
19 changes: 19 additions & 0 deletions packages/block-brokers/LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
45 changes: 45 additions & 0 deletions packages/block-brokers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<p align="center">
<a href="https://github.com/ipfs/helia" title="Helia">
<img src="https://raw.githubusercontent.com/ipfs/helia/main/assets/helia.png" alt="Helia logo" width="300" />
</a>
</p>

[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![codecov](https://img.shields.io/codecov/c/github/ipfs/helia.svg?style=flat-square)](https://codecov.io/gh/ipfs/helia)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/helia/main.yml?branch=main\&style=flat-square)](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain)

> Block brokers for Helia

## Install

```console
$ npm i @helia/block-brokers
```

<!-- ### Browser `<script>` tag

Loading this module through a script tag will make it's exports available as `bitswap` and `trustlessGateway` in the global namespace.

```html
<script src="https://unpkg.com/@helia/block-brokers/dist/index.min.js"></script>
``` -->

## License

Licensed under either of

- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)

## Contribute

Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).

Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.

Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
79 changes: 79 additions & 0 deletions packages/block-brokers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "@helia/block-brokers",
"version": "0.9.0",
"description": "Block brokers for Helia",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/helia/tree/master/packages/block-brokers#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/helia.git"
},
"bugs": {
"url": "https://github.com/ipfs/helia/issues"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"keywords": [
"IPFS"
],
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"project": true,
"sourceType": "module"
}
},
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"dep-check": "aegir dep-check",
"build": "aegir build",
"test": "aegir test",
"test:chrome": "aegir test -t browser --cov",
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:node": "aegir test -t node --cov",
"test:electron-main": "aegir test -t electron-main"
},
"dependencies": {
"@helia/interface": "^2.1.0",
"@libp2p/interface": "^1.0.1",
"any-signal": "^4.1.1",
"interface-blockstore": "^5.2.7",
"interface-store": "^5.1.5",
"ipfs-bitswap": "^20.0.0",
"it-filter": "^3.0.4",
"it-foreach": "^2.0.6",
"multiformats": "^12.1.3",
"progress-events": "^1.0.0",
"uint8arrays": "^5.0.0"
},
"devDependencies": {
"@libp2p/logger": "^4.0.1",
"@types/sinon": "^17.0.2",
"aegir": "^41.1.14",
"blockstore-core": "^4.3.8",
"delay": "^6.0.0",
"it-all": "^3.0.4",
"it-drain": "^3.0.5",
"sinon": "^17.0.1",
"sinon-ts": "^2.0.0"
}
}
12 changes: 12 additions & 0 deletions packages/block-brokers/src/utils/default-hashers.ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another file that I had duplicated @SgtPooki, it's also used in helia.ts

Davids-Computer helia % git grep -i "default-hashers"
packages/block-brokers/test/block-broker.spec.ts:import { defaultHashers } from '../src/utils/default-hashers.js'
packages/block-brokers/test/utils/networked-storage.spec.ts:import { defaultHashers } from '../../src/utils/default-hashers.js'
packages/block-brokers/typedoc.json:    "./src/utils/default-hashers.ts"
packages/helia/package.json:      "types": "./dist/src/utils/default-hashers.d.ts",
packages/helia/package.json:      "import": "./dist/src/utils/default-hashers.js"
packages/helia/src/helia.ts:import { defaultHashers } from './utils/default-hashers.js'
packages/helia/typedoc.json:    "./src/utils/default-hashers.ts"

Could move over and just export from block-brokers like NetworkedStorage

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { identity } from 'multiformats/hashes/identity'
import { sha256, sha512 } from 'multiformats/hashes/sha2'
import type { MultihashHasher } from 'multiformats/hashes/interface'

export function defaultHashers (hashers: MultihashHasher[] = []): MultihashHasher[] {
return [
sha256,
sha512,
identity,
...hashers
]
}
Loading
Loading