|
1 | | -diff --git a/core/chaincode/shim/mockstub.go b/core/chaincode/shim/mockstub.go |
2 | | -index acc8200..e808052 100644 |
3 | | ---- a/core/chaincode/shim/mockstub.go |
4 | | -+++ b/core/chaincode/shim/mockstub.go |
5 | | -@@ -12,6 +12,7 @@ import ( |
6 | | - "container/list" |
7 | | - "fmt" |
8 | | - "strings" |
9 | | -+ "sync" |
10 | | - |
11 | | - "github.com/golang/protobuf/ptypes/timestamp" |
12 | | - "github.com/hyperledger/fabric/common/util" |
13 | | -@@ -62,6 +63,10 @@ type MockStub struct { |
14 | | - |
15 | | - // channel to store ChaincodeEvents |
16 | | - ChaincodeEventsChannel chan *pb.ChaincodeEvent |
17 | | -+ |
18 | | -+ Decorations map[string][]byte |
19 | | -+ |
20 | | -+ sync.RWMutex |
21 | | - } |
22 | | - |
23 | | - func (stub *MockStub) GetTxID() string { |
24 | | -@@ -137,7 +142,7 @@ func (stub *MockStub) MockInvoke(uuid string, args [][]byte) pb.Response { |
25 | | - } |
26 | | - |
27 | | - func (stub *MockStub) GetDecorations() map[string][]byte { |
28 | | -- return nil |
29 | | -+ return stub.Decorations |
30 | | - } |
31 | | - |
32 | | - // Invoke this chaincode, also starts and ends a transaction. |
33 | | -@@ -193,6 +198,8 @@ func (stub *MockStub) GetPrivateDataQueryResult(collection, query string) (State |
34 | | - |
35 | | - // GetState retrieves the value for a given key from the ledger |
36 | | - func (stub *MockStub) GetState(key string) ([]byte, error) { |
37 | | -+ stub.RLock() |
38 | | -+ defer stub.RUnlock() |
39 | | - value := stub.State[key] |
40 | | - mockLogger.Debug("MockStub", stub.Name, "Getting", key, value) |
41 | | - return value, nil |
42 | | -@@ -200,11 +207,13 @@ func (stub *MockStub) GetState(key string) ([]byte, error) { |
43 | | - |
44 | | - // PutState writes the specified `value` and `key` into the ledger. |
45 | | - func (stub *MockStub) PutState(key string, value []byte) error { |
46 | | -- if stub.TxID == "" { |
47 | | -- err := errors.New("cannot PutState without a transactions - call stub.MockTransactionStart()?") |
48 | | -- mockLogger.Errorf("%+v", err) |
49 | | -- return err |
50 | | -- } |
51 | | -+ stub.Lock() |
52 | | -+ defer stub.Unlock() |
53 | | -+ // if stub.TxID == "" { |
54 | | -+ // err := errors.New("cannot PutState without a transactions - call stub.MockTransactionStart()?") |
55 | | -+ // mockLogger.Errorf("%+v", err) |
56 | | -+ // return err |
57 | | -+ // } |
58 | | - |
59 | | - mockLogger.Debug("MockStub", stub.Name, "Putting", key, value) |
60 | | - stub.State[key] = value |
61 | | -@@ -244,6 +253,8 @@ func (stub *MockStub) PutState(key string, value []byte) error { |
62 | | - |
63 | | - // DelState removes the specified `key` and its value from the ledger. |
64 | | - func (stub *MockStub) DelState(key string) error { |
65 | | -+ stub.Lock() |
66 | | -+ defer stub.Unlock() |
67 | | - mockLogger.Debug("MockStub", stub.Name, "Deleting", key, stub.State[key]) |
68 | | - delete(stub.State, key) |
69 | | - |
70 | | -@@ -257,6 +268,8 @@ func (stub *MockStub) DelState(key string) error { |
71 | | - } |
72 | | - |
73 | | - func (stub *MockStub) GetStateByRange(startKey, endKey string) (StateQueryIteratorInterface, error) { |
74 | | -+ stub.RLock() |
75 | | -+ defer stub.RUnlock() |
76 | | - if err := validateSimpleKeys(startKey, endKey); err != nil { |
77 | | - return nil, err |
78 | | - } |
79 | | -@@ -288,6 +301,8 @@ func (stub *MockStub) GetHistoryForKey(key string) (HistoryQueryIteratorInterfac |
80 | | - //a partial composite key. For a full composite key, an iter with empty response |
81 | | - //would be returned. |
82 | | - func (stub *MockStub) GetStateByPartialCompositeKey(objectType string, attributes []string) (StateQueryIteratorInterface, error) { |
83 | | -+ stub.RLock() |
84 | | -+ defer stub.RUnlock() |
85 | | - partialCompositeKey, err := stub.CreateCompositeKey(objectType, attributes) |
86 | | - if err != nil { |
87 | | - return nil, err |
88 | | -@@ -381,6 +396,7 @@ func NewMockStub(name string, cc Chaincode) *MockStub { |
89 | | - s.Invokables = make(map[string]*MockStub) |
90 | | - s.Keys = list.New() |
91 | | - s.ChaincodeEventsChannel = make(chan *pb.ChaincodeEvent, 100) //define large capacity for non-blocking setEvent calls. |
92 | | -+ s.Decorations = make(map[string][]byte) |
93 | | - |
94 | | - return s |
95 | | - } |
96 | | -diff --git a/core/container/dockercontroller/dockercontroller.go b/core/container/dockercontroller/dockercontroller.go |
97 | | -index a6ec99e..e5c1f69 100644 |
98 | | ---- a/core/container/dockercontroller/dockercontroller.go |
99 | | -+++ b/core/container/dockercontroller/dockercontroller.go |
| 1 | +diff --git i/core/container/dockercontroller/dockercontroller.go w/core/container/dockercontroller/dockercontroller.go |
| 2 | +index 2a709ed0b..51df8f7ff 100644 |
| 3 | +--- i/core/container/dockercontroller/dockercontroller.go |
| 4 | ++++ w/core/container/dockercontroller/dockercontroller.go |
100 | 5 | @@ -168,6 +168,14 @@ func getDockerHostConfig() *docker.HostConfig { |
101 | 6 | CPUQuota: getInt64("CpuQuota"), |
102 | 7 | CPUPeriod: getInt64("CpuPeriod"), |
103 | 8 | BlkioWeight: getInt64("BlkioWeight"), |
104 | 9 | + Binds: []string{"/var/run/aesmd:/var/run/aesmd"}, |
105 | 10 | + Devices: []docker.Device{ |
106 | | -+ docker.Device{ |
| 11 | ++ { |
107 | 12 | + PathOnHost: "/dev/isgx", |
108 | 13 | + PathInContainer: "/dev/isgx", |
109 | 14 | + CgroupPermissions: "rwm", |
110 | 15 | + }, |
111 | 16 | + }, |
112 | 17 | } |
| 18 | + } |
113 | 19 |
|
114 | | - return hostConfig |
115 | | -@@ -176,7 +184,8 @@ func getDockerHostConfig() *docker.HostConfig { |
116 | | - func (vm *DockerVM) createContainer(ctxt context.Context, client dockerClient, |
117 | | - imageID string, containerID string, args []string, |
118 | | - env []string, attachStdout bool) error { |
119 | | -- config := docker.Config{Cmd: args, Image: imageID, Env: env, AttachStdout: attachStdout, AttachStderr: attachStdout} |
120 | | -+ v := map[string]struct{}{"/var/run/aesmd": {}} |
121 | | -+ config := docker.Config{Cmd: args, Image: imageID, Env: env, AttachStdout: attachStdout, AttachStderr: attachStdout, Volumes: v} |
122 | | - copts := docker.CreateContainerOptions{Name: containerID, Config: &config, HostConfig: getDockerHostConfig()} |
123 | | - dockerLogger.Debugf("Create container: %s", containerID) |
124 | | - _, err := client.CreateContainer(copts) |
| 20 | +@@ -182,6 +190,7 @@ func (vm *DockerVM) createContainer(client dockerClient, imageID, containerID st |
| 21 | + Env: env, |
| 22 | + AttachStdout: attachStdout, |
| 23 | + AttachStderr: attachStdout, |
| 24 | ++ Volumes: map[string]struct{}{"/var/run/aesmd": {}}, |
| 25 | + }, |
| 26 | + HostConfig: getDockerHostConfig(), |
| 27 | + }) |
0 commit comments