diff --git a/Makefile b/Makefile index a519fb29..a7426553 100644 --- a/Makefile +++ b/Makefile @@ -68,11 +68,7 @@ mocks: $(MOCKGEN_CMD) -source=btcstaking-tracker/atomicslasher/expected_babylon_client.go -package atomicslasher -destination btcstaking-tracker/atomicslasher/mock_babylon_client.go $(MOCKGEN_CMD) -source=btcstaking-tracker/stakingeventwatcher/expected_babylon_client.go -package stakingeventwatcher -destination btcstaking-tracker/stakingeventwatcher/mock_babylon_client.go -update-changelog: - @echo ./scripts/update_changelog.sh $(sinceTag) $(upcomingTag) - ./scripts/update_changelog.sh $(sinceTag) $(upcomingTag) - -.PHONY: build test test-e2e build-docker rm-docker mocks update-changelog +.PHONY: build test test-e2e build-docker rm-docker mocks proto-gen: @$(call print, "Compiling protos.") diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh deleted file mode 100755 index cb35c5c1..00000000 --- a/scripts/update_changelog.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash -# This is a wrapper around `github_changelog_generator` (https://github.com/github-changelog-generator) -# to simplify / automate updating of the CHANGELOG.md file. -# -# Originally developed for CosmWasm cw_plus (https://github.com/CosmWasm/cw-plus) repository. -set -o errexit -o pipefail - -ORIGINAL_OPTS=$* -# Requires getopt from util-linux 2.37.4 (brew install gnu-getopt on Mac) -OPTS=$(getopt -l "help,release-branch:,since-tag:,future-release:,full,token:" -o "hft" -- "$@") || exit 1 - -function print_usage() { - echo -e "Usage: $0 [-h|--help] [-f|--full] [--release-branch ] [--since-tag ] [--future-release] [-t|--token ] - --h, --help Display help. --f, --full Process changes since the beginning (by default: since latest git version tag). ---since-tag Process changes since git version tag (by default: since latest git version tag). ---future-release Put the unreleased changes in the specified . ---release-branch Limit pull requests to the release branch . ---token Pass changelog github token ." -} - -function remove_opt() { - ORIGINAL_OPTS=$(echo "$ORIGINAL_OPTS" | sed "s/\\B$1\\b//") -} - -eval set -- "$OPTS" -while true -do -case $1 in - -h|--help) - print_usage - exit 0 - ;; - --since-tag) - shift - TAG="$1" - ;; - -f|--full) - TAG="" - remove_opt $1 - ;; - --) - shift - break - ;; -esac -shift -done - -# Get user and repo from ./.git/config -ORIGIN_URL=$(git config --local remote.origin.url) -GITHUB_USER=$(echo $ORIGIN_URL | sed -n 's#.*:\([^\/]*\)\/.*#\1#p') -echo "Github user: $GITHUB_USER" -GITHUB_REPO=$(echo $ORIGIN_URL | sed -n 's#.*/\([^.]*\).*#\1#p') -echo "Github repo: $GITHUB_REPO" - -if [ -z "$TAG" ] -then - # Use latest git version tag - TAG=$(git tag --sort=creatordate | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' | tail -1) - ORIGINAL_OPTS="$ORIGINAL_OPTS --since-tag $TAG" -fi - -echo "Git version tag: $TAG" - -touch CHANGELOG.md -cp CHANGELOG.md /tmp/CHANGELOG.md.$$ -# Consolidate tag for matching changelog entries -TAG=$(echo "$TAG" | sed -e 's/-\([A-Za-z]*\)[^A-Za-z]*/-\1/' -e 's/-$//') -echo "Consolidated tag: $TAG" -sed -i -n "/^## \\[${TAG}[^]]*\\]/,\$p" CHANGELOG.md - -echo github_changelog_generator -u $GITHUB_USER -p $GITHUB_REPO --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md -github_changelog_generator -u $GITHUB_USER -p $GITHUB_REPO --base CHANGELOG.md $ORIGINAL_OPTS || cp /tmp/CHANGELOG.md.$$ CHANGELOG.md - -rm -f /tmp/CHANGELOG.md.$$ diff --git a/types/blockevent.go b/types/blockevent.go deleted file mode 100644 index a06b1c90..00000000 --- a/types/blockevent.go +++ /dev/null @@ -1,29 +0,0 @@ -package types - -import "github.com/btcsuite/btcd/wire" - -type EventType int - -const ( - // BlockDisconnected indicates the associated block was disconnected - // from the main chain. - BlockDisconnected EventType = iota - - // BlockConnected indicates the associated block was connected to the - // main chain. - BlockConnected -) - -type BlockEvent struct { - EventType EventType - Height int32 - Header *wire.BlockHeader -} - -func NewBlockEvent(eventType EventType, height int32, header *wire.BlockHeader) *BlockEvent { - return &BlockEvent{ - EventType: eventType, - Height: height, - Header: header, - } -} diff --git a/types/utils.go b/types/utils.go index bb39fd52..ca766d20 100644 --- a/types/utils.go +++ b/types/utils.go @@ -22,7 +22,7 @@ func (c SupportedBtcNetwork) String() string { } func GetWrappedTxs(msg *wire.MsgBlock) []*btcutil.Tx { - btcTxs := []*btcutil.Tx{} + btcTxs := make([]*btcutil.Tx, 0, len(msg.Transactions)) for i := range msg.Transactions { newTx := btcutil.NewTx(msg.Transactions[i]) diff --git a/utils/channelutils.go b/utils/channel.go similarity index 63% rename from utils/channelutils.go rename to utils/channel.go index a9475817..323966b1 100644 --- a/utils/channelutils.go +++ b/utils/channel.go @@ -1,6 +1,6 @@ package utils -// push msg to channel c, or quit if quit channel is closed +// PushOrQuit push msg to channel c, or quit if quit channel is closed func PushOrQuit[T any](c chan<- T, msg T, quit <-chan struct{}) { select { case c <- msg: