-
Notifications
You must be signed in to change notification settings - Fork 8.8k
/
util.go
34 lines (28 loc) · 913 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
Copyright IBM Corp. 2017 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package server
import (
"io/ioutil"
"github.com/hyperledger/fabric/common/ledger/blockledger"
"github.com/hyperledger/fabric/common/ledger/blockledger/fileledger"
"github.com/hyperledger/fabric/common/metrics"
config "github.com/hyperledger/fabric/orderer/common/localconfig"
"github.com/pkg/errors"
)
func createLedgerFactory(conf *config.TopLevel, metricsProvider metrics.Provider) (blockledger.Factory, string, error) {
ld := conf.FileLedger.Location
var err error
if ld == "" {
if ld, err = ioutil.TempDir("", conf.FileLedger.Prefix); err != nil {
logger.Panic("Error creating temp dir:", err)
}
}
logger.Debug("Ledger dir:", ld)
lf, err := fileledger.New(ld, metricsProvider)
if err != nil {
return nil, "", errors.WithMessage(err, "Error in opening ledger factory")
}
return lf, ld, nil
}