Skip to content

Commit c681914

Browse files
committed
chore: run golines
Use ``` golines -w --ignore-generated --chain-split-dots --max-len=80 --reformat-tags . ``` Signed-off-by: Chris Gianelloni <[email protected]>
1 parent ef78048 commit c681914

File tree

15 files changed

+201
-48
lines changed

15 files changed

+201
-48
lines changed

cmd/snek/main.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,20 @@ func main() {
9595

9696
// Start debug listener
9797
if cfg.Debug.ListenPort > 0 {
98-
logger.Infof("starting debug listener on %s:%d", cfg.Debug.ListenAddress, cfg.Debug.ListenPort)
98+
logger.Infof(
99+
"starting debug listener on %s:%d",
100+
cfg.Debug.ListenAddress,
101+
cfg.Debug.ListenPort,
102+
)
99103
go func() {
100-
err := http.ListenAndServe(fmt.Sprintf("%s:%d", cfg.Debug.ListenAddress, cfg.Debug.ListenPort), nil)
104+
err := http.ListenAndServe(
105+
fmt.Sprintf(
106+
"%s:%d",
107+
cfg.Debug.ListenAddress,
108+
cfg.Debug.ListenPort,
109+
),
110+
nil,
111+
)
101112
if err != nil {
102113
logger.Fatalf("failed to start debug listener: %s", err)
103114
}

event/event.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ type Event struct {
2525
Payload interface{} `json:"payload"`
2626
}
2727

28-
func New(eventType string, timestamp time.Time, context, payload interface{}) Event {
28+
func New(
29+
eventType string,
30+
timestamp time.Time,
31+
context, payload interface{},
32+
) Event {
2933
return Event{
3034
Type: eventType,
3135
Timestamp: timestamp,

fcm/message.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ func NewMessage(token string, opts ...MessageOption) *Message {
6161

6262
func Send(accessToken string, projectId string, msg *Message) error {
6363

64-
fcmEndpoint := fmt.Sprintf("https://fcm.googleapis.com/v1/projects/%s/messages:send", projectId)
64+
fcmEndpoint := fmt.Sprintf(
65+
"https://fcm.googleapis.com/v1/projects/%s/messages:send",
66+
projectId,
67+
)
6568

6669
// Convert the message to JSON
6770
payload, err := json.Marshal(msg)

input/chainsync/chainsync.go

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ func (c *ChainSync) Start() error {
8383
}
8484
if c.bulkMode && !c.intersectTip && c.oConn.BlockFetch() != nil {
8585
var err error
86-
c.bulkRangeStart, c.bulkRangeEnd, err = c.oConn.ChainSync().Client.GetAvailableBlockRange(c.intersectPoints)
86+
c.bulkRangeStart, c.bulkRangeEnd, err = c.oConn.ChainSync().Client.GetAvailableBlockRange(
87+
c.intersectPoints,
88+
)
8789
if err != nil {
8890
return err
8991
}
@@ -142,7 +144,11 @@ func (c *ChainSync) setupConnection() error {
142144
// If network has well-known public root address/port, use those as our dial default
143145
if network.PublicRootAddress != "" && network.PublicRootPort > 0 {
144146
dialFamily = "tcp"
145-
dialAddress = fmt.Sprintf("%s:%d", network.PublicRootAddress, network.PublicRootPort)
147+
dialAddress = fmt.Sprintf(
148+
"%s:%d",
149+
network.PublicRootAddress,
150+
network.PublicRootPort,
151+
)
146152
useNtn = true
147153
}
148154
}
@@ -199,13 +205,25 @@ func (c *ChainSync) setupConnection() error {
199205
return nil
200206
}
201207

202-
func (c *ChainSync) handleRollBackward(point ocommon.Point, tip ochainsync.Tip) error {
203-
evt := event.New("chainsync.rollback", time.Now(), nil, NewRollbackEvent(point))
208+
func (c *ChainSync) handleRollBackward(
209+
point ocommon.Point,
210+
tip ochainsync.Tip,
211+
) error {
212+
evt := event.New(
213+
"chainsync.rollback",
214+
time.Now(),
215+
nil,
216+
NewRollbackEvent(point),
217+
)
204218
c.eventChan <- evt
205219
return nil
206220
}
207221

208-
func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip ochainsync.Tip) error {
222+
func (c *ChainSync) handleRollForward(
223+
blockType uint,
224+
blockData interface{},
225+
tip ochainsync.Tip,
226+
) error {
209227
switch v := blockData.(type) {
210228
case ledger.Block:
211229
evt := event.New("chainsync.block", time.Now(), NewBlockContext(v, c.networkMagic), NewBlockEvent(v, c.includeCbor))
@@ -230,13 +248,34 @@ func (c *ChainSync) handleRollForward(blockType uint, blockData interface{}, tip
230248
}
231249

232250
func (c *ChainSync) handleBlockFetchBlock(block ledger.Block) error {
233-
blockEvt := event.New("chainsync.block", time.Now(), NewBlockContext(block, c.networkMagic), NewBlockEvent(block, c.includeCbor))
251+
blockEvt := event.New(
252+
"chainsync.block",
253+
time.Now(),
254+
NewBlockContext(block, c.networkMagic),
255+
NewBlockEvent(block, c.includeCbor),
256+
)
234257
c.eventChan <- blockEvt
235258
for t, transaction := range block.Transactions() {
236-
txEvt := event.New("chainsync.transaction", time.Now(), NewTransactionContext(block, transaction, uint32(t), c.networkMagic), NewTransactionEvent(block, transaction, c.includeCbor))
259+
txEvt := event.New(
260+
"chainsync.transaction",
261+
time.Now(),
262+
NewTransactionContext(
263+
block,
264+
transaction,
265+
uint32(t),
266+
c.networkMagic,
267+
),
268+
NewTransactionEvent(block, transaction, c.includeCbor),
269+
)
237270
c.eventChan <- txEvt
238271
}
239-
c.updateStatus(block.SlotNumber(), block.BlockNumber(), block.Hash(), c.bulkRangeEnd.Slot, hex.EncodeToString(c.bulkRangeEnd.Hash))
272+
c.updateStatus(
273+
block.SlotNumber(),
274+
block.BlockNumber(),
275+
block.Hash(),
276+
c.bulkRangeEnd.Slot,
277+
hex.EncodeToString(c.bulkRangeEnd.Hash),
278+
)
240279
// Start normal chain-sync if we've reached the last block of our bulk range
241280
if block.SlotNumber() == c.bulkRangeEnd.Slot {
242281
if err := c.oConn.ChainSync().Client.Sync([]ocommon.Point{c.bulkRangeEnd}); err != nil {
@@ -246,7 +285,13 @@ func (c *ChainSync) handleBlockFetchBlock(block ledger.Block) error {
246285
return nil
247286
}
248287

249-
func (c *ChainSync) updateStatus(slotNumber uint64, blockNumber uint64, blockHash string, tipSlotNumber uint64, tipBlockHash string) {
288+
func (c *ChainSync) updateStatus(
289+
slotNumber uint64,
290+
blockNumber uint64,
291+
blockHash string,
292+
tipSlotNumber uint64,
293+
tipBlockHash string,
294+
) {
250295
// Determine if we've reached the chain tip
251296
if !c.status.TipReached {
252297
// Make sure we're past the end slot in any bulk range, since we don't update the tip during bulk sync

input/chainsync/options.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ func WithIncludeCbor(includeCbor bool) ChainSyncOptionFunc {
7878

7979
// WithStatusUpdateFunc specifies a callback function for status updates. This is useful for tracking the chain-sync status
8080
// to be able to resume a sync at a later time, especially when any filtering could prevent you from getting all block update events
81-
func WithStatusUpdateFunc(statusUpdateFunc StatusUpdateFunc) ChainSyncOptionFunc {
81+
func WithStatusUpdateFunc(
82+
statusUpdateFunc StatusUpdateFunc,
83+
) ChainSyncOptionFunc {
8284
return func(c *ChainSync) {
8385
c.statusUpdateFunc = statusUpdateFunc
8486
}

input/chainsync/plugin.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ func NewFromCmdlineOptions() plugin.Plugin {
131131
if len(intersectPointParts) != 2 {
132132
panic("invalid intersect point format")
133133
}
134-
intersectSlot, err := strconv.ParseUint(intersectPointParts[0], 10, 64)
134+
intersectSlot, err := strconv.ParseUint(
135+
intersectPointParts[0],
136+
10,
137+
64,
138+
)
135139
if err != nil {
136140
panic("invalid intersect point format")
137141
}

input/chainsync/tx.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ type TransactionEvent struct {
3737
TTL uint64 `json:"ttl,omitempty"`
3838
}
3939

40-
func NewTransactionContext(block ledger.Block, tx ledger.Transaction, index uint32, networkMagic uint32) TransactionContext {
40+
func NewTransactionContext(
41+
block ledger.Block,
42+
tx ledger.Transaction,
43+
index uint32,
44+
networkMagic uint32,
45+
) TransactionContext {
4146
ctx := TransactionContext{
4247
BlockNumber: block.BlockNumber(),
4348
SlotNumber: block.SlotNumber(),
@@ -48,7 +53,11 @@ func NewTransactionContext(block ledger.Block, tx ledger.Transaction, index uint
4853
return ctx
4954
}
5055

51-
func NewTransactionEvent(block ledger.Block, tx ledger.Transaction, includeCbor bool) TransactionEvent {
56+
func NewTransactionEvent(
57+
block ledger.Block,
58+
tx ledger.Transaction,
59+
includeCbor bool,
60+
) TransactionEvent {
5261
evt := TransactionEvent{
5362
BlockHash: block.Hash(),
5463
Inputs: tx.Inputs(),

internal/config/config.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ type Config struct {
3535
Version bool `yaml:"-"`
3636
Logging LoggingConfig `yaml:"logging"`
3737
Debug DebugConfig `yaml:"debug"`
38-
Input string `yaml:"input" envconfig:"INPUT"`
39-
Output string `yaml:"output" envconfig:"OUTPUT"`
38+
Input string `yaml:"input" envconfig:"INPUT"`
39+
Output string `yaml:"output" envconfig:"OUTPUT"`
4040
Plugin map[string]map[string]map[interface{}]interface{} `yaml:"plugins"`
4141
}
4242

@@ -46,7 +46,7 @@ type LoggingConfig struct {
4646

4747
type DebugConfig struct {
4848
ListenAddress string `yaml:"address" envconfig:"DEBUG_ADDRESS"`
49-
ListenPort uint `yaml:"port" envconfig:"DEBUG_PORT"`
49+
ListenPort uint `yaml:"port" envconfig:"DEBUG_PORT"`
5050
}
5151

5252
// Singleton config instance with default values
@@ -88,8 +88,18 @@ func (c *Config) ParseCmdlineArgs(programName string, args []string) error {
8888
fs := flag.NewFlagSet(programName, flag.ExitOnError)
8989
fs.StringVar(&c.ConfigFile, "config", "", "path to config file to load")
9090
fs.BoolVar(&c.Version, "version", false, "show version and exit")
91-
fs.StringVar(&c.Input, "input", DefaultInputPlugin, "input plugin to use, 'list' to show available")
92-
fs.StringVar(&c.Output, "output", DefaultOutputPlugin, "output plugin to use, 'list' to show available")
91+
fs.StringVar(
92+
&c.Input,
93+
"input",
94+
DefaultInputPlugin,
95+
"input plugin to use, 'list' to show available",
96+
)
97+
fs.StringVar(
98+
&c.Output,
99+
"output",
100+
DefaultOutputPlugin,
101+
"output plugin to use, 'list' to show available",
102+
)
93103
if err := plugin.PopulateCmdlineOptions(fs); err != nil {
94104
return err
95105
}

internal/logging/logging.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ func Configure() {
3535
// Change timestamp key name
3636
loggerConfig.EncoderConfig.TimeKey = "timestamp"
3737
// Use a human readable time format
38-
loggerConfig.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(time.RFC3339)
38+
loggerConfig.EncoderConfig.EncodeTime = zapcore.TimeEncoderOfLayout(
39+
time.RFC3339,
40+
)
3941

4042
// Set level
4143
if cfg.Logging.Level != "" {
@@ -65,5 +67,7 @@ func GetDesugaredLogger() *zap.Logger {
6567
}
6668

6769
func GetAccessLogger() *zap.Logger {
68-
return globalLogger.Desugar().With(zap.String("type", "access")).WithOptions(zap.WithCaller(false))
70+
return globalLogger.Desugar().
71+
With(zap.String("type", "access")).
72+
WithOptions(zap.WithCaller(false))
6973
}

output/notify/notify.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ func (n *NotifyOutput) Start() error {
6464
bc := context.(chainsync.BlockContext)
6565
err := beeep.Notify(
6666
n.title,
67-
fmt.Sprintf("New Block!\nBlockNumber: %d, SlotNumber: %d\nHash: %s",
67+
fmt.Sprintf(
68+
"New Block!\nBlockNumber: %d, SlotNumber: %d\nHash: %s",
6869
bc.BlockNumber,
6970
bc.SlotNumber,
7071
be.BlockHash,
@@ -106,7 +107,8 @@ func (n *NotifyOutput) Start() error {
106107
tc := context.(chainsync.TransactionContext)
107108
err := beeep.Notify(
108109
n.title,
109-
fmt.Sprintf("New Transaction!\nBlockNumber: %d, SlotNumber: %d\nInputs: %d, Outputs: %d\nFee: %d\nHash: %s",
110+
fmt.Sprintf(
111+
"New Transaction!\nBlockNumber: %d, SlotNumber: %d\nInputs: %d, Outputs: %d\nFee: %d\nHash: %s",
110112
tc.BlockNumber,
111113
tc.SlotNumber,
112114
len(te.Inputs),

0 commit comments

Comments
 (0)