Skip to content

Commit

Permalink
Merge pull request #206 from bitcoin-sv/chore/587-migrate-pulse-name
Browse files Browse the repository at this point in the history
chore(BUX-587): rename pulse -> Block Headers Service
  • Loading branch information
dorzepowski authored Feb 14, 2024
2 parents f70c6ce + faac61b commit ae343bf
Show file tree
Hide file tree
Showing 146 changed files with 596 additions and 777 deletions.
2 changes: 1 addition & 1 deletion .github/CODE_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ Additional information and guidelines on Conventional Commits can be found [here
Good example:

```bash
feat: add possibility to create a new user by admin (#BUX-123)
feat(#123): add possibility to create a new user by admin
```

Bad example:
Expand Down
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# Pull Request Checklist

- [ ] 📖 I created my PR using provided : [CODE_STANDARDS](https://github.com/bitcoin-sv/pulse/blob/main/.github/CODE_STANDARDS.md)
- [ ] 📖 I have read the short Code of Conduct: [CODE_OF_CONDUCT](https://github.com/bitcoin-sv/pulse/blob/main/.github/CODE_OF_CONDUCT.md)
- [ ] 📖 I created my PR using provided : [CODE_STANDARDS](https://github.com/bitcoin-sv/block-headers-service/blob/main/.github/CODE_STANDARDS.md)
- [ ] 📖 I have read the short Code of Conduct: [CODE_OF_CONDUCT](https://github.com/bitcoin-sv/block-headers-service/blob/main/.github/CODE_OF_CONDUCT.md)
- [ ] 🏠 I tested my changes locally.
- [ ] ✅ I have provided tests for my changes.
- [ ] 📝 I have used conventional commits.
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ artifacts/
dist/
data/blockheaders.bck.db
data/blockheaders.db-journal
data/blockheaders.csv
data/*-blockheaders.csv
config.yaml


*.db*
Expand Down
76 changes: 0 additions & 76 deletions CODE_OF_CONDUCT.md

This file was deleted.

34 changes: 0 additions & 34 deletions CODE_STANDARDS.md

This file was deleted.

30 changes: 0 additions & 30 deletions CONTRIBUTING.md

This file was deleted.

4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ENV GOPATH=/
COPY ./ ./

RUN go mod download
RUN go build -o pulse ./cmd/
RUN go build -o block-headers-service ./cmd/

CMD ["./pulse"]
CMD ["./block-headers-service"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ 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.

The pulse software, were licensed under the MIT License, which is included below.
The block-headers-service software, were licensed under the MIT License, which is included below.

MIT License

Expand Down
59 changes: 29 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[![Release](https://img.shields.io/github/release-pre/libsv/pulse.svg?logo=github&style=flat&v=1)](https://github.com/libsv/pulse/releases)
[![Build Status](https://img.shields.io/github/workflow/status/libsv/pulse/go?logo=github&v=3)](https://github.com/libsv/pulse/actions)
[![Report](https://goreportcard.com/badge/github.com/libsv/pulse?style=flat&v=1)](https://goreportcard.com/report/github.com/libsv/pulse)
[![Go](https://img.shields.io/github/go-mod/go-version/libsv/pulse?v=1)](https://golang.org/)
[![Sponsor](https://img.shields.io/badge/sponsor-libsv-181717.svg?logo=github&style=flat&v=3)](https://github.com/sponsors/libsv)
[![Release](https://img.shields.io/github/release-pre/bitcoin-sv/block-headers-service.svg?logo=github&style=flat&v=1)](https://github.com/bitcoin-sv/block-headers-service/releases)
[![Build Status](https://img.shields.io/github/workflow/status/bitcoin-sv/block-headers-service/go?logo=github&v=3)](https://github.com/bitcoin-sv/block-headers-service/actions)
[![Report](https://goreportcard.com/badge/github.com/bitcoin-sv/block-headers-service?style=flat&v=1)](https://goreportcard.com/report/github.com/bitcoin-sv/block-headers-service)
[![Go](https://img.shields.io/github/go-mod/go-version/bitcoin-sv/block-headers-service?v=1)](https://golang.org/)
[![Sponsor](https://img.shields.io/badge/sponsor-bitcoin-sv-181717.svg?logo=github&style=flat&v=3)](https://github.com/sponsors/bitcoin-sv)
[![Donate](https://img.shields.io/badge/donate-bitcoin-ff9900.svg?logo=bitcoin&style=flat&v=3)](https://gobitcoinsv.com/#sponsor)
<br />

<h1 id="top" align="center">Pulse</h1>
<h1 id="top" align="center">Block Headers Service</h1>

<p align="center">
Go application used to collect and return information about blockchain headers
Expand Down Expand Up @@ -57,8 +57,7 @@
<!-- ABOUT THE PROJECT -->
## About The Project


Pulse is a go server which connects into BSV P2P network to gather and then serve information about all exisiting and new headers. It is build to work as a standaolne app or a module in bigger system.
Block header service is a go service which connects into BSV P2P network to gather and then serve information about all exisiting and new headers. It is build to work as a standaolne app or a module in bigger system.

#### Main functionality
The main functionality of the application is synchornization with peers and collecting all headers. After starting the server, it creates default objects and connects to BSV P2P network. Application has defined checkpoints (specific headers) which are used in synchronization. During this process, server is asking peers for headers (from checkpoint to checkpoint) in batches of 2000. Every header received from peers is saved in memory. After full synchronization, server is changing the operating mode and start to listening for new header. After when new block has been mined, this information should be sended from peers to our server.
Expand All @@ -67,11 +66,11 @@ The main functionality of the application is synchornization with peers and coll

### Docker image

Pull image from docker hub https://hub.docker.com/r/bsvb/pulse
1. ```docker pull bsvb/pulse```
Pull image from docker hub https://hub.docker.com/r/bsvb/block-headers-service
1. ```docker pull bsvb/block-headers-service```

Starting new instance
1. ```docker run bsvb/pulse:latest```
1. ```docker run bsvb/block-headers-service:latest```


### Endpoints documentation
Expand Down Expand Up @@ -100,17 +99,17 @@ as it would then be possible for anyone to prune your headers at will.
#### Authenticate with admin token

After the setup of authentication you can use provided token to authenticate.
To do it, just add the following header to all the requests to pulse
To do it, just add the following header to all the requests to block-headers-service.
```
Authorization Bearer replace_me_with_token_you_want_to_use_as_admin_token
```

#### Additional tokens

If you have a need for additional tokens to authenticate in pulse
If you have a need for additional tokens to authenticate in block-headers-service.
you can generate such with the following request:
```http request
POST https://{{pulse_url}}/api/v1/access
POST https://{{block-headers-service_url}}/api/v1/access
Authorization: Bearer replace_me_with_token_you_want_to_use_as_admin_token
```
In response you should receive something like
Expand All @@ -128,18 +127,18 @@ Authorization: Bearer some_token_created_by_server

If at some point you want to revoke this additional token you can make a request:
```http request
DELETE https://{{pulse_url}}/api/v1/access/{{some_token_created_by_server}}
DELETE https://{{block-headers-service_url}}/api/v1/access/{{some_token_created_by_server}}
Authorization: Bearer replace_me_with_token_you_want_to_use_as_admin_token
```
After this request succeeded the token can't be used to authenticate in pulse.
After this request succeeded the token can't be used to authenticate in block-headers-service.

### Websocket

Pulse can notify a client via websockets that new header was received and store by it.
Block headers service can notify a client via websockets that new header was received and store by it.

#### Subscribing

Pulse use [centrifugal/centrifuge](https://github.com/centrifugal/centrifuge) to run a server.
Block headers service use [centrifugal/centrifuge](https://github.com/centrifugal/centrifuge) to run a server.
Therefore, to integrate you need to choose a client library matching a programming language of your choice.

Example how to subscribe using GO lang library [centrifugal/centrifuge-go](https://github.com/centrifugal/centrifuge-go)
Expand All @@ -150,7 +149,7 @@ can be found in [./examples/ws-subscribe-to-new-headers/](./examples/ws-subscrib
#### Creating webhook
Creating a new webhook is done via POST request
```http request
POST https://{{pulse_url}}/api/v1/webhook
POST https://{{block-headers-service_url}}/api/v1/webhook
```

Data which should be sent in body:
Expand Down Expand Up @@ -188,13 +187,13 @@ After that webhook is created and will be informed about new headers.
#### Check webhook
To check webhook you can use the GET request which will return webhook object (same as when creating new webhook) from which you can get all the information
```http request
GET https://{{pulse_url}}/api/v1/webhook?url={{webhook_url}}
GET https://{{block-headers-service_url}}/api/v1/webhook?url={{webhook_url}}
```

#### Revoke webhook
If you want to revoke webhook you can use the following request:
```http request
DELETE https://{{pulse_url}}/api/v1/webhook?url={{webhook_url}}
DELETE https://{{block-headers-service_url}}/api/v1/webhook?url={{webhook_url}}
```
This request will delete webhook permanently

Expand All @@ -205,22 +204,22 @@ If the number of failed requests wil exceed `WEBHOOK_MAXTRIES`, webhook will be

1. Install Go according to the installation instructions here: http://golang.org/doc/install

Options to run Pulse:
Options to run Block Headers Service:

a) Clone the repo

```sh
git clone https://github.com/bitcoin-sv/pulse
git clone https://github.com/bitcoin-sv/block-headers-service
```
1. ```go run ./cmd/main.go```

Or run app with docker
1. ```docker compose up --build```

b) Get package from ``pkg.dev.go``
1. ```go get -u https://pkg.go.dev/github.com/bitcoin-sv/pulse```
2. ```go build -o pulse```
3. ```./pulse```
1. ```go get -u https://pkg.go.dev/github.com/bitcoin-sv/block-headers-service```
2. ```go build -o block-headers-service```
3. ```./block-headers-service```


## Usage
Expand All @@ -229,7 +228,7 @@ b) Get package from ``pkg.dev.go``

### Defaults

If you run Pulse without editing anything, it will use the default configuration from file [defaults.go](/config/defaults.go). It is set up to use _sqlite_ database with enabled authorization (with default auth key) for http server.
If you run block headers service without editing anything, it will use the default configuration from file [defaults.go](/config/defaults.go). It is set up to use _sqlite_ database with enabled authorization (with default auth key) for http server.

### Config Variables

Expand Down Expand Up @@ -265,7 +264,7 @@ go run ./cmd/main.go -C /my/config.yaml

#### Environment variables

To override any config variable with ENV, use the "pulse\_" prefix with mapstructure annotation path with "_" as a delimiter in all uppercase. Example:
To override any config variable with ENV, use the "headers-service\_" prefix with mapstructure annotation path with "_" as a delimiter in all uppercase. Example:

Let's take this fragment of AppConfig from `config.example.yaml`:
Expand All @@ -277,10 +276,10 @@ websocket:
history_ttl: 10
```
To override history_max in websocket config, use the path with "_" as a path delimiter and pulse\_ as prefix. So:
To override history_max in websocket config, use the path with "_" as a path delimiter and bhs\_ as prefix. So:
```bash
PULSE_HISTORY_MAX=300
BHS_HISTORY_MAX=300
```
Expand Down
Loading

0 comments on commit ae343bf

Please sign in to comment.