Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"net"
"sync"
"time"
Expand Down Expand Up @@ -59,6 +60,7 @@ type Connection struct {
networkMagic uint32
server bool
useNodeToNodeProto bool
logger *slog.Logger
muxer *muxer.Muxer
errorChan chan error
protoErrorChan chan error
Expand Down
10 changes: 9 additions & 1 deletion connection_options.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Blink Labs Software
// Copyright 2024 Blink Labs Software
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
package ouroboros

import (
"log/slog"
"net"

"github.com/blinklabs-io/gouroboros/protocol/blockfetch"
Expand Down Expand Up @@ -66,6 +67,13 @@ func WithServer(server bool) ConnectionOptionFunc {
}
}

// WithLogger specifies the slog.Logger to use. This is empty by default
func WithLogger(logger *slog.Logger) ConnectionOptionFunc {
return func(c *Connection) {
c.logger = logger
}
}

// WithNodeToNode specifies whether to use the node-to-node protocol. The default is to use node-to-client
func WithNodeToNode(nodeToNode bool) ConnectionOptionFunc {
return func(c *Connection) {
Expand Down