From f70f87ca94cebb4135fb102b6a13e47e34a1b882 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Wed, 30 Aug 2023 18:14:05 -0400 Subject: [PATCH] fix: quiet golangci-lint (mostly) Signed-off-by: Chris Gianelloni --- internal/indexer/indexer.go | 10 ++++++---- internal/miner/nonce.go | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/internal/indexer/indexer.go b/internal/indexer/indexer.go index ebc72ba..03ac302 100644 --- a/internal/indexer/indexer.go +++ b/internal/indexer/indexer.go @@ -23,7 +23,7 @@ type Indexer struct { } type Datum struct { - nonce []byte + nonce uint64 state State } @@ -121,11 +121,13 @@ func (i *Indexer) handleEvent(evt event.Event) error { return err } datumFields := datum.Value().(cbor.Constructor).Fields() - nonce := datumFields[0] - state := datumFields[1] + var data = Datum{ + nonce: datumFields[0].(uint64), + } + state := datumFields[1].(cbor.ByteString).String() // TODO: do the thing - logger.Infof("found updated datum: nonce: %d, state: %#v", nonce, state) + logger.Infof("found updated datum: nonce: %d, state: %s", data.nonce, state) } } return nil diff --git a/internal/miner/nonce.go b/internal/miner/nonce.go index 934fa19..21c5ce2 100644 --- a/internal/miner/nonce.go +++ b/internal/miner/nonce.go @@ -1,10 +1,25 @@ +// Copyright 2023 Blink Labs, LLC. +// +// 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 miner import "crypto/rand" func GenerateNonce() []byte { nonce := make([]byte, 16) - rand.Read(nonce) + // toss error + _, _ = rand.Read(nonce) return nonce }