Skip to content

Commit 3b19da1

Browse files
authored
Merge pull request #878 from kaleido-io/definitions2
Enable non-multiparty namespaces
2 parents 1c398f0 + 784a4db commit 3b19da1

File tree

128 files changed

+2729
-1671
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+2729
-1671
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ $(eval $(call makemock, internal/broadcast, Manager, broadcast
6262
$(eval $(call makemock, internal/privatemessaging, Manager, privatemessagingmocks))
6363
$(eval $(call makemock, internal/shareddownload, Manager, shareddownloadmocks))
6464
$(eval $(call makemock, internal/shareddownload, Callbacks, shareddownloadmocks))
65-
$(eval $(call makemock, internal/definitions, DefinitionHandler, definitionsmocks))
65+
$(eval $(call makemock, internal/definitions, Handler, definitionsmocks))
66+
$(eval $(call makemock, internal/definitions, Sender, definitionsmocks))
6667
$(eval $(call makemock, internal/events, EventManager, eventmocks))
6768
$(eval $(call makemock, internal/namespace, Manager, namespacemocks))
6869
$(eval $(call makemock, internal/networkmap, Manager, networkmapmocks))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- No down migration (can't add back NOT NULL constraint)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
BEGIN;
2+
ALTER TABLE identities RENAME COLUMN messages_claim TO messages_claim_old;
3+
ALTER TABLE identities ADD COLUMN messages_claim UUID;
4+
UPDATE identities SET messages_claim = messages_claim_old;
5+
ALTER TABLE identities DROP COLUMN messages_claim_old;
6+
7+
ALTER TABLE ffi RENAME COLUMN message_id TO message_id_old;
8+
ALTER TABLE ffi ADD COLUMN message_id UUID;
9+
UPDATE ffi SET message_id = message_id_old;
10+
ALTER TABLE ffi DROP COLUMN message_id_old;
11+
12+
ALTER TABLE contractapis RENAME COLUMN message_id TO message_id_old;
13+
ALTER TABLE contractapis ADD COLUMN message_id UUID;
14+
UPDATE contractapis SET message_id = message_id_old;
15+
ALTER TABLE contractapis DROP COLUMN message_id_old;
16+
COMMIT;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- No down migration (can't add back NOT NULL constraint)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
ALTER TABLE identities RENAME COLUMN messages_claim TO messages_claim_old;
2+
ALTER TABLE identities ADD COLUMN messages_claim UUID;
3+
UPDATE identities SET messages_claim = messages_claim_old;
4+
ALTER TABLE identities DROP COLUMN messages_claim_old;
5+
6+
ALTER TABLE ffi RENAME COLUMN message_id TO message_id_old;
7+
ALTER TABLE ffi ADD COLUMN message_id UUID;
8+
UPDATE ffi SET message_id = message_id_old;
9+
ALTER TABLE ffi DROP COLUMN message_id_old;
10+
11+
ALTER TABLE contractapis RENAME COLUMN message_id TO message_id_old;
12+
ALTER TABLE contractapis ADD COLUMN message_id UUID;
13+
UPDATE contractapis SET message_id = message_id_old;
14+
ALTER TABLE contractapis DROP COLUMN message_id_old;

docs/reference/config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ nav_order: 2
336336

337337
|Key|Description|Type|Default Value|
338338
|---|-----------|----|-------------|
339-
|type|The Data Exchange plugin to use|`string`|`ffdx`
339+
|type|The Data Exchange plugin to use|`string`|`<nil>`
340340

341341
## dataexchange.ffdx
342342

@@ -585,11 +585,11 @@ nav_order: 2
585585

586586
|Key|Description|Type|Default Value|
587587
|---|-----------|----|-------------|
588-
|defaultKey|A default signing key for blockchain transactions within this namespace|`string`|`<nil>`
588+
|defaultkey|A default signing key for blockchain transactions within this namespace|`string`|`<nil>`
589589
|description|A description for the namespace|`string`|`<nil>`
590590
|name|The name of the namespace (must be unique)|`string`|`<nil>`
591591
|plugins|The list of plugins for this namespace|`string`|`<nil>`
592-
|remoteName|The namespace name to be sent in plugin calls, if it differs from namespace name|`string`|`<nil>`
592+
|remotename|The namespace name to be sent in plugin calls, if it differs from namespace name|`string`|`<nil>`
593593

594594
## namespaces.predefined[].multiparty
595595

internal/apiserver/route_get_data_blob.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/hyperledger/firefly-common/pkg/ffapi"
2424
"github.com/hyperledger/firefly/internal/coremsgs"
25+
"github.com/hyperledger/firefly/internal/orchestrator"
2526
"github.com/hyperledger/firefly/pkg/core"
2627
"github.com/hyperledger/firefly/pkg/database"
2728
)
@@ -40,6 +41,9 @@ var getDataBlob = &ffapi.Route{
4041
JSONOutputCodes: []int{http.StatusOK},
4142
Extensions: &coreExtensions{
4243
FilterFactory: database.MessageQueryFactory,
44+
EnabledIf: func(or orchestrator.Orchestrator) bool {
45+
return or.MultiParty() != nil
46+
},
4347
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
4448
blob, reader, err := cr.or.Data().DownloadBlob(cr.ctx, r.PP["dataid"])
4549
if err == nil {

internal/apiserver/route_get_data_blob_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"github.com/hyperledger/firefly-common/pkg/fftypes"
2626
"github.com/hyperledger/firefly/mocks/datamocks"
27+
"github.com/hyperledger/firefly/mocks/multipartymocks"
2728
"github.com/hyperledger/firefly/pkg/core"
2829
"github.com/stretchr/testify/assert"
2930
"github.com/stretchr/testify/mock"
@@ -33,6 +34,7 @@ func TestGetDataBlob(t *testing.T) {
3334
o, r := newTestAPIServer()
3435
mdm := &datamocks.Manager{}
3536
o.On("Data").Return(mdm)
37+
o.On("MultiParty").Return(&multipartymocks.Manager{})
3638
req := httptest.NewRequest("GET", "/api/v1/namespaces/mynamespace/data/abcd1234/blob", nil)
3739
req.Header.Set("Content-Type", "application/json; charset=utf-8")
3840
res := httptest.NewRecorder()

internal/apiserver/route_get_group_by_id.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/hyperledger/firefly-common/pkg/ffapi"
2323
"github.com/hyperledger/firefly/internal/coremsgs"
24+
"github.com/hyperledger/firefly/internal/orchestrator"
2425
"github.com/hyperledger/firefly/pkg/core"
2526
)
2627

@@ -37,9 +38,11 @@ var getGroupByHash = &ffapi.Route{
3738
JSONOutputValue: func() interface{} { return &core.Group{} },
3839
JSONOutputCodes: []int{http.StatusOK},
3940
Extensions: &coreExtensions{
41+
EnabledIf: func(or orchestrator.Orchestrator) bool {
42+
return or.PrivateMessaging() != nil
43+
},
4044
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
41-
output, err = cr.or.PrivateMessaging().GetGroupByID(cr.ctx, r.PP["hash"])
42-
return output, err
45+
return cr.or.PrivateMessaging().GetGroupByID(cr.ctx, r.PP["hash"])
4346
},
4447
},
4548
}

internal/apiserver/route_get_groups.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/hyperledger/firefly-common/pkg/ffapi"
2323
"github.com/hyperledger/firefly/internal/coremsgs"
24+
"github.com/hyperledger/firefly/internal/orchestrator"
2425
"github.com/hyperledger/firefly/pkg/core"
2526
"github.com/hyperledger/firefly/pkg/database"
2627
)
@@ -37,6 +38,9 @@ var getGroups = &ffapi.Route{
3738
JSONOutputCodes: []int{http.StatusOK},
3839
Extensions: &coreExtensions{
3940
FilterFactory: database.GroupQueryFactory,
41+
EnabledIf: func(or orchestrator.Orchestrator) bool {
42+
return or.PrivateMessaging() != nil
43+
},
4044
CoreJSONHandler: func(r *ffapi.APIRequest, cr *coreRequest) (output interface{}, err error) {
4145
return filterResult(cr.or.PrivateMessaging().GetGroups(cr.ctx, cr.filter))
4246
},

0 commit comments

Comments
 (0)