From 3802e127827c782c0d05f1a9673644b8bcbddad0 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Thu, 7 Mar 2024 12:11:28 -0500 Subject: [PATCH] feat: configure localtxmonitor client (#116) Signed-off-by: Chris Gianelloni --- go.mod | 2 +- go.sum | 4 ++-- internal/node/localtxmonitor.go | 35 +++++++++++++++++++++++++++++++++ internal/node/node.go | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 internal/node/localtxmonitor.go diff --git a/go.mod b/go.mod index 9d4a278..eda4372 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/blinklabs-io/cardano-node-api go 1.20 require ( - github.com/blinklabs-io/gouroboros v0.72.0 + github.com/blinklabs-io/gouroboros v0.73.0 github.com/fxamacker/cbor/v2 v2.6.0 github.com/gin-contrib/zap v1.1.0 github.com/gin-gonic/gin v1.9.1 diff --git a/go.sum b/go.sum index 41fff67..1593c34 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/blinklabs-io/gouroboros v0.72.0 h1:HI9DFQ3wi+pr8iOPH7jOr31rNRf2ij7jA2v3dv+2vOQ= -github.com/blinklabs-io/gouroboros v0.72.0/go.mod h1:1Vpk6pm86JBKHi5riBQv4EAKixX+XvttWv1o6DewLBg= +github.com/blinklabs-io/gouroboros v0.73.0 h1:ZbTUoWo7KgDxOHhIqnWFOTrIJtcr6S5XmPQ5eEU//hE= +github.com/blinklabs-io/gouroboros v0.73.0/go.mod h1:cvu7kpPIso3IS5Dexfq4m7sMnyLMsLFOE5jjDBEtC7E= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A= diff --git a/internal/node/localtxmonitor.go b/internal/node/localtxmonitor.go new file mode 100644 index 0000000..44e732c --- /dev/null +++ b/internal/node/localtxmonitor.go @@ -0,0 +1,35 @@ +// 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. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package node + +import ( + "time" + + "github.com/blinklabs-io/gouroboros/protocol/localtxmonitor" + + "github.com/blinklabs-io/cardano-node-api/internal/config" +) + +func buildLocalTxMonitorConfig() localtxmonitor.Config { + cfg := config.GetConfig() + return localtxmonitor.NewConfig( + localtxmonitor.WithAcquireTimeout( + time.Duration(cfg.Node.Timeout) * time.Second, + ), + localtxmonitor.WithQueryTimeout( + time.Duration(cfg.Node.Timeout) * time.Second, + ), + ) +} diff --git a/internal/node/node.go b/internal/node/node.go index 91be4ae..f63909c 100644 --- a/internal/node/node.go +++ b/internal/node/node.go @@ -31,6 +31,7 @@ func GetConnection() (*ouroboros.Connection, error) { ouroboros.WithNodeToNode(false), ouroboros.WithKeepAlive(true), ouroboros.WithChainSyncConfig(buildChainSyncConfig()), + ouroboros.WithLocalTxMonitorConfig(buildLocalTxMonitorConfig()), ouroboros.WithLocalTxSubmissionConfig(buildLocalTxSubmissionConfig()), ) if err != nil {