From f4815bdc6782ddbdb86d338f165f9cdbe94c4554 Mon Sep 17 00:00:00 2001 From: Victoria Erokhina Date: Mon, 3 Mar 2025 19:57:38 +0000 Subject: [PATCH] fix block hashes format --- pkg/api/liteserver_converters.go | 38 ++++++++++++-------------------- pkg/api/liteserver_handlers.go | 10 ++------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/pkg/api/liteserver_converters.go b/pkg/api/liteserver_converters.go index 5cace782..af1714b3 100644 --- a/pkg/api/liteserver_converters.go +++ b/pkg/api/liteserver_converters.go @@ -23,31 +23,26 @@ func errChain(mappings ...error) error { return nil } -func convertMasterchainInfo(info liteclient.LiteServerMasterchainInfoC) (*oas.GetRawMasterchainInfoOK, error) { +func convertMasterchainInfo(info liteclient.LiteServerMasterchainInfoC) *oas.GetRawMasterchainInfoOK { convertedInfo := oas.GetRawMasterchainInfoOK{ Last: oas.BlockRaw{ Workchain: int32(info.Last.Workchain), Shard: fmt.Sprintf("%016x", info.Last.Shard), Seqno: int32(info.Last.Seqno), + RootHash: fmt.Sprintf("%x", info.Last.RootHash), + FileHash: fmt.Sprintf("%x", info.Last.FileHash), }, Init: oas.InitStateRaw{ Workchain: int32(info.Init.Workchain), + RootHash: fmt.Sprintf("%x", info.Init.RootHash), + FileHash: fmt.Sprintf("%x", info.Init.FileHash), }, + StateRootHash: fmt.Sprintf("%x", info.StateRootHash), } - err := errChain( - toJson(&convertedInfo.Last.RootHash, info.Last.RootHash), - toJson(&convertedInfo.Last.FileHash, info.Last.FileHash), - toJson(&convertedInfo.StateRootHash, info.StateRootHash), - toJson(&convertedInfo.Init.RootHash, info.Init.RootHash), - toJson(&convertedInfo.Init.FileHash, info.Init.FileHash), - ) - if err != nil { - return nil, err - } - return &convertedInfo, nil + return &convertedInfo } -func convertMasterchainInfoExt(info liteclient.LiteServerMasterchainInfoExtC) (*oas.GetRawMasterchainInfoExtOK, error) { +func convertMasterchainInfoExt(info liteclient.LiteServerMasterchainInfoExtC) *oas.GetRawMasterchainInfoExtOK { convertedInfo := oas.GetRawMasterchainInfoExtOK{ Mode: int32(info.Mode), Version: int32(info.Version), @@ -56,24 +51,19 @@ func convertMasterchainInfoExt(info liteclient.LiteServerMasterchainInfoExtC) (* Workchain: int32(info.Last.Workchain), Shard: fmt.Sprintf("%016x", info.Last.Shard), Seqno: int32(info.Last.Seqno), + RootHash: fmt.Sprintf("%x", info.Last.RootHash), + FileHash: fmt.Sprintf("%x", info.Last.FileHash), }, LastUtime: int32(info.LastUtime), Now: int32(info.Now), Init: oas.InitStateRaw{ Workchain: int32(info.Init.Workchain), + RootHash: fmt.Sprintf("%x", info.Init.RootHash), + FileHash: fmt.Sprintf("%x", info.Init.FileHash), }, + StateRootHash: fmt.Sprintf("%x", info.StateRootHash), } - err := errChain( - toJson(&convertedInfo.Last.RootHash, info.Last.RootHash), - toJson(&convertedInfo.Last.FileHash, info.Last.FileHash), - toJson(&convertedInfo.StateRootHash, info.StateRootHash), - toJson(&convertedInfo.Init.RootHash, info.Init.RootHash), - toJson(&convertedInfo.Init.FileHash, info.Init.FileHash), - ) - if err != nil { - return nil, err - } - return &convertedInfo, nil + return &convertedInfo } func convertBlock(block liteclient.LiteServerBlockDataC) (*oas.GetRawBlockchainBlockOK, error) { diff --git a/pkg/api/liteserver_handlers.go b/pkg/api/liteserver_handlers.go index 42efe111..8c098629 100644 --- a/pkg/api/liteserver_handlers.go +++ b/pkg/api/liteserver_handlers.go @@ -16,10 +16,7 @@ func (h *Handler) GetRawMasterchainInfo(ctx context.Context) (*oas.GetRawMasterc if err != nil { return nil, toError(http.StatusInternalServerError, err) } - resp, err := convertMasterchainInfo(info) - if err != nil { - return nil, toError(http.StatusInternalServerError, err) - } + resp := convertMasterchainInfo(info) return resp, nil } @@ -28,10 +25,7 @@ func (h *Handler) GetRawMasterchainInfoExt(ctx context.Context, params oas.GetRa if err != nil { return nil, toError(http.StatusBadRequest, err) } - resp, err := convertMasterchainInfoExt(info) - if err != nil { - return nil, toError(http.StatusInternalServerError, err) - } + resp := convertMasterchainInfoExt(info) return resp, nil }