Skip to content

Commit 1551196

Browse files
committed
Upgrading to candy 0.1.5
1 parent a34056b commit 1551196

6 files changed

Lines changed: 77 additions & 67 deletions

File tree

dfx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"packtool": "vessel sources"
2121
}
2222
},
23-
"dfx": "0.8.3",
23+
"dfx": "0.9.2",
2424
"networks": {
2525
"local": {
2626
"bind": "127.0.0.1:8000",

package-set.dhall

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
let upstream = https://github.com/dfinity/vessel-package-set/releases/download/mo-0.6.4-20210624/package-set.dhall sha256:3f4cffd315d8ee5d2b4b5b00dc03b2e02732345b565340b7cb9cc0001444f525
1+
let upstream = https://github.com/dfinity/vessel-package-set/releases/download/mo-0.6.21-20220215/package-set.dhall sha256:b46f30e811fe5085741be01e126629c2a55d4c3d6ebf49408fb3b4a98e37589b
22
let Package =
33
{ name : Text, version : Text, repo : Text, dependencies : List Text }
44

55
let additions =
66
[
77
{ name = "candy"
88
, repo = "https://github.com/aramakme/candy_library.git"
9-
, version = "v0.1.1"
9+
, version = "v0.1.5"
1010
, dependencies = ["base"]
1111
},
1212
{ name = "principal"
@@ -15,12 +15,20 @@ let additions =
1515
, dependencies = ["base"]
1616
}] : List Package
1717

18-
let overrides =
19-
[{
20-
name = "base",
21-
repo = "https://github.com/dfinity/motoko-base",
22-
version = "dfx-0.7.2",
23-
dependencies = [] : List Text
24-
}] : List Package
18+
let
19+
{- This is where you can override existing packages in the package-set
20+
21+
For example, if you wanted to use version `v2.0.0` of the foo library:
22+
let overrides = [
23+
{ name = "foo"
24+
, version = "v2.0.0"
25+
, repo = "https://github.com/bar/foo"
26+
, dependencies = [] : List Text
27+
}
28+
]
29+
-}
30+
overrides =
31+
[] : List Package
32+
2533

2634
in upstream # additions # overrides

src/lib.mo

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import Nat64 "mo:base/Nat64";
1919
import Nat "mo:base/Nat";
2020
import Result "mo:base/Result";
2121
import PipelinifyTypes "types";
22-
import Candy "mo:candy";
22+
import Candy "mo:candy/types";
23+
import Workspace "mo:candy/workspace";
2324
import Debug "mo:base/Debug";
2425
import Buffer "mo:base/Buffer";
2526
import Hash "mo:base/Hash";
@@ -200,7 +201,7 @@ module {
200201
case(null){
201202
func _getLocalWorkspace(_hash : PipeInstanceID, _id : Nat, _request: ?PipelinifyTypes.ProcessRequest) : Candy.Workspace{
202203
//just returns what it was given
203-
return Candy.emptyWorkspace();
204+
return Workspace.emptyWorkspace();
204205

205206
}
206207
};
@@ -213,7 +214,7 @@ module {
213214
case(null){
214215
func _putLocalWorkspacee(_hash : PipeInstanceID, _id : Nat, _workspace: Candy.Workspace, _request: ?PipelinifyTypes.ProcessRequest) : Candy.Workspace{
215216
//just returns what it was given
216-
return Candy.emptyWorkspace();
217+
return Workspace.emptyWorkspace();
217218

218219
}
219220
};
@@ -317,7 +318,7 @@ module {
317318
let dataWillBeReturnedResponse = onDataWillBeReturned(pipeInstanceID, finalData, ?_request);
318319
let processResponse =
319320
#dataIncluded{
320-
payload = Candy.workspaceToAddressedChunkArray(finalData);
321+
payload = Workspace.workspaceToAddressedChunkArray(finalData);
321322
};
322323
let dataReturnedResponse : PipelinifyTypes.PipelineEventResponse = onDataReturned(pipeInstanceID, ?_request, ?processResponse);
323324

@@ -365,7 +366,7 @@ module {
365366
let pipeInstanceID = getPipeInstanceID(_request);
366367

367368
Debug.print("the process is on");
368-
var thisWorkspace = Candy.emptyWorkspace();
369+
var thisWorkspace = Workspace.emptyWorkspace();
369370

370371

371372

@@ -389,7 +390,7 @@ module {
389390
let dataWillLoadResponse = onDataWillBeLoaded(pipeInstanceID, ?_request);
390391
//todo: chunk data into workspace
391392

392-
thisWorkspace := Candy.fromAddressedChunks(dataIncludedRequest.data);
393+
thisWorkspace := Workspace.fromAddressedChunks(dataIncludedRequest.data);
393394
Debug.print("workspace included" # debug_show(thisWorkspace.size()));
394395
let dataResponse : PipelinifyTypes.PipelineEventResponse = onDataReady(pipeInstanceID, thisWorkspace, ?_request);
395396
};
@@ -405,15 +406,15 @@ module {
405406
Debug.print("initilizing cache with no data");
406407
workspaceCache.put(pipeInstanceID, {
407408
var status = #initialized;
408-
data = Candy.emptyWorkspace();
409+
data = Workspace.emptyWorkspace();
409410
});
410411
bInitilized := true;
411412
};
412413
case(?data){
413414
Debug.print("initilizing cache with data");
414415
bInitilized := true;
415416
bLoading := true;
416-
Candy.fileAddressedChunks(thisWorkspace, data);
417+
Workspace.fileAddressedChunks(thisWorkspace, data);
417418
chunkCount := 1;
418419
};
419420
};
@@ -472,18 +473,18 @@ module {
472473
case(#chunk(chunkData)){
473474
Debug.print("found some Data");
474475
//dataChunks := Array.append<PipelinifyTypes.AddressedChunk>(dataChunks, Array.make<PipelinifyTypes.AddressedChunk>(chunkData));
475-
Candy.fileAddressedChunks(thisWorkspace, chunkData);
476+
Workspace.fileAddressedChunks(thisWorkspace, chunkData);
476477
chunkCount := chunkCount + 1;
477478
};
478479
case(#eof(chunkData)){
479480
Debug.print("found some eof data");
480-
Candy.fileAddressedChunks(thisWorkspace, chunkData);
481+
Workspace.fileAddressedChunks(thisWorkspace, chunkData);
481482
chunkCount := chunkCount + 1;
482483
break dataRetrieve;
483484
};
484485
case(#parallel(chunkData)){
485486
Debug.print("found some parallel data");
486-
Candy.fileAddressedChunks(thisWorkspace, chunkData.2);
487+
Workspace.fileAddressedChunks(thisWorkspace, chunkData.2);
487488
chunkCount := chunkCount + 1;
488489
break dataRetrieve;
489490
};
@@ -516,7 +517,7 @@ module {
516517
//todo: maybe we require initialization
517518
workspaceCache.put(pipeInstanceID, {
518519
var status = #initialized;
519-
data = Candy.emptyWorkspace();
520+
data = Workspace.emptyWorkspace();
520521
});
521522
return #ok(#intakeNeeded{
522523
pipeInstanceID = pipeInstanceID;
@@ -754,7 +755,7 @@ module {
754755
};
755756

756757
//Debug.print("chunk data " # debug_show(chunkData[1]) # debug_show(chunkData[2]) # debug_show(chunkData[3]) # debug_show(chunkData[4]) # debug_show(chunkData[5]));
757-
Candy.fileAddressedChunks(thisCache.data, chunkData);
758+
Workspace.fileAddressedChunks(thisCache.data, chunkData);
758759
};
759760

760761

@@ -766,7 +767,7 @@ module {
766767
Debug.print("hit EOF Chunk");
767768
thisCache.status := #doneLoading;
768769
//Debug.print("eof data " # debug_show(chunkData[1]) # debug_show(chunkData[2]) # debug_show(chunkData[3]) # debug_show(chunkData[4]) # debug_show(chunkData[5]) );
769-
Candy.fileAddressedChunks(thisCache.data, chunkData);
770+
Workspace.fileAddressedChunks(thisCache.data, chunkData);
770771

771772
};
772773
case(#parallel(chunkData)){
@@ -776,7 +777,7 @@ module {
776777
let thisMap = Array.init<Bool>(chunkData.1,false);
777778
thisMap[chunkData.0] := true;
778779
thisCache.status := #loading(chunkData.0, chunkData.1, Array.freeze<Bool>(thisMap));
779-
Candy.fileAddressedChunks(thisCache.data, chunkData.2);
780+
Workspace.fileAddressedChunks(thisCache.data, chunkData.2);
780781
return #ok(#intakeNeeded{
781782
pipeInstanceID = _request.pipeInstanceID;
782783
currentChunks = chunkData.0;
@@ -790,7 +791,7 @@ module {
790791
let thisMap = Array.thaw<Bool>(loadingVal.2);
791792
thisMap[chunkData.0] := true;
792793
thisCache.status := #loading(chunkData.0,chunkData.1, Array.freeze<Bool>(thisMap));
793-
Candy.fileAddressedChunks(thisCache.data, chunkData.2);
794+
Workspace.fileAddressedChunks(thisCache.data, chunkData.2);
794795
Debug.print("map is " # debug_show(thisMap));
795796
return #ok(#intakeNeeded{
796797
pipeInstanceID = _request.pipeInstanceID;
@@ -998,7 +999,7 @@ module {
998999
return #err({text="Cannot find response Cache for ID" # Nat32.toText(_request.pipeInstanceID); code= 13;});
9991000
};
10001001
case(?thisCache){
1001-
let result = Candy.getWorkspaceChunk(thisCache.data, _request.chunkID, _request.chunkSize);
1002+
let result = Workspace.getWorkspaceChunk(thisCache.data, _request.chunkID, _request.chunkSize);
10021003
switch(result.0){
10031004
case(#eof){
10041005
return #ok(#eof(result.1.toArray()));

src/types.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Principal "mo:base/Principal";
2222
import Result "mo:base/Result";
2323
import String "mo:base/Text";
2424
import Text "mo:base/Text";
25-
import Candy "mo:candy";
25+
import Candy "mo:candy/types";
2626

2727

2828
module {

0 commit comments

Comments
 (0)