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

Function store

blockproducer/storage.go:127–153  ·  view source on GitHub ↗
(st xi.Storage, sps []storageProcedure, cb storageCallback)

Source from the content-addressed store, hash-verified

125type storageCallback func()
126
127func store(st xi.Storage, sps []storageProcedure, cb storageCallback) (err error) {
128 var tx *sql.Tx
129 // BEGIN
130 if tx, err = st.Writer().Begin(); err != nil {
131 return
132 }
133 log.Debugf("started database tx %p", tx)
134 // ROLLBACK on failure
135 defer tx.Rollback()
136 // WRITE
137 for _, sp := range sps {
138 if err = sp(tx); err != nil {
139 return
140 }
141 }
142 // CALLBACK: MUST NOT FAIL
143 if cb != nil {
144 cb()
145 log.Debugf("invoked storage callback %p in tx %p", cb, tx)
146 }
147 // COMMIT
148 if err = tx.Commit(); err != nil {
149 log.WithError(err).Fatal("failed to commit storage transaction")
150 }
151 log.Debugf("committed database tx %p", tx)
152 return
153}
154
155func errPass(err error) storageProcedure {
156 return func(_ *sql.Tx) error {

Callers 5

TestChainFunction · 0.85
NewChainWithContextFunction · 0.85
storeTxMethod · 0.85
applyBlockMethod · 0.85

Calls 7

DebugfFunction · 0.92
WithErrorFunction · 0.92
FatalMethod · 0.80
WriterMethod · 0.65
RollbackMethod · 0.65
CommitMethod · 0.65
BeginMethod · 0.45

Tested by 1

TestChainFunction · 0.68