From d9a379d3fa4a8e5fbde67e9bc447a80e5c24a1f5 Mon Sep 17 00:00:00 2001 From: fearlseefe <505380967@qq.com> Date: Wed, 11 Sep 2024 16:36:29 +0800 Subject: [PATCH] fix: lint error --- portalnetwork/beacon/beacon_network.go | 26 +++++++++++++------------- portalnetwork/beacon/test_utils.go | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/portalnetwork/beacon/beacon_network.go b/portalnetwork/beacon/beacon_network.go index 5ef5f64ea5d4..e5518d98ebff 100644 --- a/portalnetwork/beacon/beacon_network.go +++ b/portalnetwork/beacon/beacon_network.go @@ -321,19 +321,19 @@ func (bn *BeaconNetwork) processContentLoop(ctx context.Context) { func (bn *BeaconNetwork) generalSummariesValidation(contentKey, content []byte) (*ForkedHistoricalSummariesWithProof, error) { key := &HistoricalSummariesWithProofKey{} - err := key.Deserialize(codec.NewDecodingReader(bytes.NewReader(contentKey[1:]), uint64(len(contentKey[1:])))) - if err != nil { - return nil, err - } - forkedHistoricalSummariesWithProof := &ForkedHistoricalSummariesWithProof{} - err = forkedHistoricalSummariesWithProof.Deserialize(bn.spec, codec.NewDecodingReader(bytes.NewReader(content), uint64(len(content)))) - if err != nil { - return nil, err - } - if forkedHistoricalSummariesWithProof.HistoricalSummariesWithProof.EPOCH != common.Epoch(key.Epoch) { - return nil, fmt.Errorf("historical summaries with proof epoch does not match the content key epoch: %d != %d", forkedHistoricalSummariesWithProof.HistoricalSummariesWithProof.EPOCH, key.Epoch) - } - return forkedHistoricalSummariesWithProof, nil + err := key.Deserialize(codec.NewDecodingReader(bytes.NewReader(contentKey[1:]), uint64(len(contentKey[1:])))) + if err != nil { + return nil, err + } + forkedHistoricalSummariesWithProof := &ForkedHistoricalSummariesWithProof{} + err = forkedHistoricalSummariesWithProof.Deserialize(bn.spec, codec.NewDecodingReader(bytes.NewReader(content), uint64(len(content)))) + if err != nil { + return nil, err + } + if forkedHistoricalSummariesWithProof.HistoricalSummariesWithProof.EPOCH != common.Epoch(key.Epoch) { + return nil, fmt.Errorf("historical summaries with proof epoch does not match the content key epoch: %d != %d", forkedHistoricalSummariesWithProof.HistoricalSummariesWithProof.EPOCH, key.Epoch) + } + return forkedHistoricalSummariesWithProof, nil } func (bn *BeaconNetwork) stateSummariesValidation(f ForkedHistoricalSummariesWithProof, latestFinalizedRoot common.Root) bool { diff --git a/portalnetwork/beacon/test_utils.go b/portalnetwork/beacon/test_utils.go index fcc3530d45b7..9f0550e54871 100644 --- a/portalnetwork/beacon/test_utils.go +++ b/portalnetwork/beacon/test_utils.go @@ -165,18 +165,18 @@ func GetHistorySummariesWithProof() (HistoricalSummariesWithProof, common.Root, } data, err := snappy.Decode(nil, file) if err != nil { - return HistoricalSummariesWithProof{}, common.Root{},err + return HistoricalSummariesWithProof{}, common.Root{}, err } beaconState := &deneb.BeaconState{} err = beaconState.Deserialize(configs.Mainnet, codec.NewDecodingReader(bytes.NewReader(data), uint64(len(data)))) if err != nil { - return HistoricalSummariesWithProof{}, common.Root{},err + return HistoricalSummariesWithProof{}, common.Root{}, err } root := beaconState.HashTreeRoot(configs.Mainnet, tree.GetHashFn()) proof, err := BuildHistoricalSummariesProof(*beaconState) if err != nil { - return HistoricalSummariesWithProof{}, common.Root{},err + return HistoricalSummariesWithProof{}, common.Root{}, err } summariesProof := [5]common.Bytes32{tree.Root(proof[0]), tree.Root(proof[1]), tree.Root(proof[2]), tree.Root(proof[3]), tree.Root(proof[4])} return HistoricalSummariesWithProof{