From d4731b916e9e190bf9be56dff831f9cfafbeb206 Mon Sep 17 00:00:00 2001 From: "Leo Zhang (zhangchiqing)" Date: Fri, 13 Oct 2023 08:15:48 -0700 Subject: [PATCH] making ReadTriesRootHash public --- ledger/complete/wal/checkpoint_v6_reader.go | 4 +++- ledger/complete/wal/checkpoint_v6_test.go | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ledger/complete/wal/checkpoint_v6_reader.go b/ledger/complete/wal/checkpoint_v6_reader.go index e39b66452c5..de17333b95e 100644 --- a/ledger/complete/wal/checkpoint_v6_reader.go +++ b/ledger/complete/wal/checkpoint_v6_reader.go @@ -20,6 +20,8 @@ import ( // ErrEOFNotReached for indicating end of file not reached error var ErrEOFNotReached = errors.New("expect to reach EOF, but actually didn't") +var ReadTriesRootHash = readTriesRootHash + // readCheckpointV6 reads checkpoint file from a main file and 17 file parts. // the main file stores: // - version @@ -632,7 +634,7 @@ func readTopLevelTries(dir string, fileName string, subtrieNodes [][]*node.Node, return tries, nil } -func readTriesRootHash(dir string, fileName string, logger zerolog.Logger) ( +func readTriesRootHash(logger zerolog.Logger, dir string, fileName string) ( trieRoots []ledger.RootHash, errToReturn error, ) { diff --git a/ledger/complete/wal/checkpoint_v6_test.go b/ledger/complete/wal/checkpoint_v6_test.go index 28d08e3f4e9..d414244ea9e 100644 --- a/ledger/complete/wal/checkpoint_v6_test.go +++ b/ledger/complete/wal/checkpoint_v6_test.go @@ -598,7 +598,7 @@ func TestReadCheckpointRootHash(t *testing.T) { logger := unittest.Logger() require.NoErrorf(t, StoreCheckpointV6Concurrently(tries, dir, fileName, logger), "fail to store checkpoint") - trieRoots, err := readTriesRootHash(dir, fileName, logger) + trieRoots, err := readTriesRootHash(logger, dir, fileName) require.NoError(t, err) for i, root := range trieRoots { expectedHash := tries[i].RootHash() @@ -615,7 +615,7 @@ func TestReadCheckpointRootHashMulti(t *testing.T) { logger := unittest.Logger() require.NoErrorf(t, StoreCheckpointV6Concurrently(tries, dir, fileName, logger), "fail to store checkpoint") - trieRoots, err := readTriesRootHash(dir, fileName, logger) + trieRoots, err := readTriesRootHash(logger, dir, fileName) require.NoError(t, err) for i, root := range trieRoots { expectedHash := tries[i].RootHash()