-
Notifications
You must be signed in to change notification settings - Fork 255
/
store.go
35 lines (29 loc) · 922 Bytes
/
store.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
35
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package store store the world - state data
package store
import (
"github.com/33cn/chain33/queue"
"github.com/33cn/chain33/types"
)
// Storecreate store queue module
type Storecreate func(cfg *types.Store, sub []byte, chain33cfg *types.Chain33Config) queue.Module
var regStore = make(map[string]Storecreate)
// Reg 注册 store driver
func Reg(name string, create Storecreate) {
if create == nil {
panic("Store: Register driver is nil")
}
if _, dup := regStore[name]; dup {
panic("Store: Register called twice for driver " + name)
}
regStore[name] = create
}
// Load load StoreCreate by name
func Load(name string) (create Storecreate, err error) {
if driver, ok := regStore[name]; ok {
return driver, nil
}
return nil, types.ErrNotFound
}