From 0b3d6ee34398581a5cf6e4c5f5a91fb31a8b9cc8 Mon Sep 17 00:00:00 2001 From: Aurora Gaffney Date: Sat, 18 Jan 2025 19:56:02 -0600 Subject: [PATCH] refactor: move VrfResult to common and use for Shelley block header (#835) --- ledger/babbage/babbage.go | 8 +------- ledger/common/vrf.go | 25 +++++++++++++++++++++++++ ledger/shelley/shelley.go | 4 ++-- 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 ledger/common/vrf.go diff --git a/ledger/babbage/babbage.go b/ledger/babbage/babbage.go index 1daa256b..b54f14ce 100644 --- a/ledger/babbage/babbage.go +++ b/ledger/babbage/babbage.go @@ -140,12 +140,6 @@ func (b *BabbageBlock) Utxorpc() *utxorpc.Block { return block } -type BabbageBlockHeaderVrfResult struct { - cbor.StructAsArray - Output []byte - Proof []byte -} - type BabbageBlockHeader struct { cbor.StructAsArray cbor.DecodeStoreCbor @@ -157,7 +151,7 @@ type BabbageBlockHeader struct { PrevHash common.Blake2b256 IssuerVkey common.IssuerVkey VrfKey []byte - VrfResult BabbageBlockHeaderVrfResult + VrfResult common.VrfResult BlockBodySize uint64 BlockBodyHash common.Blake2b256 OpCert struct { diff --git a/ledger/common/vrf.go b/ledger/common/vrf.go new file mode 100644 index 00000000..371fa145 --- /dev/null +++ b/ledger/common/vrf.go @@ -0,0 +1,25 @@ +// 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 common + +import ( + "github.com/blinklabs-io/gouroboros/cbor" +) + +type VrfResult struct { + cbor.StructAsArray + Output []byte + Proof []byte +} diff --git a/ledger/shelley/shelley.go b/ledger/shelley/shelley.go index d0cab22b..798ca198 100644 --- a/ledger/shelley/shelley.go +++ b/ledger/shelley/shelley.go @@ -140,8 +140,8 @@ type ShelleyBlockHeader struct { PrevHash common.Blake2b256 IssuerVkey common.IssuerVkey VrfKey []byte - NonceVrf interface{} - LeaderVrf interface{} + NonceVrf common.VrfResult + LeaderVrf common.VrfResult BlockBodySize uint64 BlockBodyHash common.Blake2b256 OpCertHotVkey []byte