Skip to content

Commit

Permalink
feat: make miner message configurable
Browse files Browse the repository at this point in the history
Fixes #235
  • Loading branch information
agaffney committed Jul 30, 2024
1 parent 291bec4 commit 3060e8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
7 changes: 5 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"os"
"runtime"

"github.com/blinklabs-io/bluefin/internal/version"
ouroboros "github.com/blinklabs-io/gouroboros"
"github.com/kelseyhightower/envconfig"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -62,8 +63,9 @@ type WalletConfig struct {
}

type MinerConfig struct {
WorkerCount int `yaml:"workers" envconfig:"WORKER_COUNT"`
HashRateInterval int `yaml:"hashRateInterval" envconfig:"HASH_RATE_INTERVAL"`
WorkerCount int `yaml:"workers" envconfig:"WORKER_COUNT"`
HashRateInterval int `yaml:"hashRateInterval" envconfig:"HASH_RATE_INTERVAL"`
Message string `yaml:"message" envconfig:"MINER_MESSAGE"`
}

type LoggingConfig struct {
Expand Down Expand Up @@ -104,6 +106,7 @@ var globalConfig = &Config{
Miner: MinerConfig{
WorkerCount: max(1, runtime.NumCPU()/2),
HashRateInterval: 60,
Message: fmt.Sprintf("Bluefin %s by Blink Labs", version.GetVersionString()),
},
Network: "mainnet",
Profile: "tuna-v1",
Expand Down
12 changes: 3 additions & 9 deletions internal/miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/blinklabs-io/bluefin/internal/config"
"github.com/blinklabs-io/bluefin/internal/logging"
"github.com/blinklabs-io/bluefin/internal/storage"
"github.com/blinklabs-io/bluefin/internal/version"
"github.com/blinklabs-io/bluefin/internal/wallet"

models "github.com/blinklabs-io/cardano-models"
Expand Down Expand Up @@ -208,7 +207,7 @@ func (m *Miner) Start() {
0,
cbor.IndefLengthList{
userPkh,
[]byte(fmt.Sprintf("Bluefin %s by Blink Labs", version.GetVersionString())),
[]byte(cfg.Miner.Message),

Check failure on line 210 in internal/miner/miner.go

View workflow job for this annotation

GitHub Actions / go-test (1.22.x, ubuntu-latest)

undefined: cfg
},
)
minerCredCbor, err := cbor.Encode(&minerCredential)
Expand Down Expand Up @@ -302,13 +301,8 @@ func (m *Miner) Start() {
DifficultyNumber: difficultyNumber,
EpochTime: epochTime,
RealTimeNow: 90000 + realTimeNow,
Extra: []byte(
fmt.Sprintf(
"Bluefin %s by Blink Labs",
version.GetVersionString(),
),
),
Interlink: currentInterlink,
Extra: []byte(cfg.Miner.Message),

Check failure on line 304 in internal/miner/miner.go

View workflow job for this annotation

GitHub Actions / go-test (1.22.x, ubuntu-latest)

undefined: cfg
Interlink: currentInterlink,
}
} else {
blockData := m.blockData.(models.TunaV2State)
Expand Down
3 changes: 1 addition & 2 deletions internal/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"github.com/blinklabs-io/bluefin/internal/config"
"github.com/blinklabs-io/bluefin/internal/logging"
"github.com/blinklabs-io/bluefin/internal/storage"
"github.com/blinklabs-io/bluefin/internal/version"
"github.com/blinklabs-io/bluefin/internal/wallet"
)

Expand Down Expand Up @@ -238,7 +237,7 @@ func createTx(blockData any, nonce [16]byte) ([]byte, error) {
0,
cbor.IndefLengthList{
userPkh,
[]byte(fmt.Sprintf("Bluefin %s by Blink Labs", version.GetVersionString())),
[]byte(cfg.Miner.Message),
},
)
// Convert old and new block numbers to byte representation for use in token names
Expand Down

0 comments on commit 3060e8d

Please sign in to comment.