MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / NewChain

Function NewChain

xenomint/chain.go:40–60  ·  view source on GitHub ↗

NewChain returns new chain instance.

(filename string)

Source from the content-addressed store, hash-verified

38
39// NewChain returns new chain instance.
40func NewChain(filename string) (c *Chain, err error) {
41 var (
42 strg xi.Storage
43 priv *ca.PrivateKey
44 )
45 // generate empty nodeId
46 nodeID := proto.NodeID("0000000000000000000000000000000000000000000000000000000000000000")
47
48 // TODO(leventeliu): add multiple storage engine support.
49 if strg, err = xs.NewSqlite(filename); err != nil {
50 return
51 }
52 if priv, err = kms.GetLocalPrivateKey(); err != nil {
53 return
54 }
55 c = &Chain{
56 state: NewState(sql.LevelReadUncommitted, nodeID, strg),
57 priv: priv,
58 }
59 return
60}
61
62// Query queries req from local chain state and returns the query results in resp.
63func (c *Chain) Query(req *types.Request) (resp *types.Response, err error) {

Callers 1

setupChainFunction · 0.70

Calls 3

NodeIDTypeAlias · 0.92
GetLocalPrivateKeyFunction · 0.92
NewStateFunction · 0.85

Tested by 1

setupChainFunction · 0.56