diff --git a/internal/indexer/indexer.go b/internal/indexer/indexer.go index 227f944..98638e2 100644 --- a/internal/indexer/indexer.go +++ b/internal/indexer/indexer.go @@ -24,7 +24,7 @@ type Indexer struct { } type Datum struct { - nonce []byte + nonce uint64 state State } @@ -147,11 +147,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 }