-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchaincode_init.go
More file actions
30 lines (25 loc) · 861 Bytes
/
chaincode_init.go
File metadata and controls
30 lines (25 loc) · 861 Bytes
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
package hlfq
import (
"github.com/pkg/errors"
"github.com/s7techlab/cckit/router"
)
// **
// ** Chaincode methods **
// **
// EmptyItemPointerKey HEAD or TAIL value when queue is empty
var EmptyItemPointerKey []string = []string{"*EMPTY*"}
func invokeInitLedger(c router.Context) (interface{}, error) {
var headPointer *QueuePointer = NewQueueHeadPointer()
headPointer.PointerKey = EmptyItemPointerKey
var tailPointer *QueuePointer = NewQueueTailPointer()
tailPointer.PointerKey = EmptyItemPointerKey
// init place to store a head pointer
if err := c.State().Insert(headPointer); err != nil {
return nil, errors.Wrap(err, "failed to init head pointer store")
}
// init place to store a tail pointer
if err := c.State().Insert(tailPointer); err != nil {
return nil, errors.Wrap(err, "failed to init tail pointer store")
}
return nil, nil
}