Skip to content

Commit

Permalink
exposer settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
panindustrial-dev committed Apr 14, 2024
1 parent eb0d0f9 commit df223cd
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mops.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "icrc3-mo"
version = "0.2.5"
version = "0.2.6"
description = "icrc3 for motoko"
repository = "https://github.com/PanIndustrial-Org/icrc3.mo"
keywords = [ "ledger", "transactions", "log" ]
Expand Down
46 changes: 46 additions & 0 deletions src/lib.mo
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ module {
public type GetBlocksArgs = MigrationTypes.Current.GetBlocksArgs;
public type GetBlocksResult = MigrationTypes.Current.GetBlocksResult;

public type UpdateSetting = MigrationTypes.Current.UpdateSetting;

/// Represents the IC actor
public type IC = MigrationTypes.Current.IC;

Expand Down Expand Up @@ -447,6 +449,50 @@ module {
return;
};


public func update_settings(settings : [UpdateSetting]) : [Bool]{

let results = Vec.new<Bool>();
for(setting in settings.vals()){
Vec.add(results, switch(setting) {
case(#maxActiveRecords(maxActiveRecords)){
state.constants.archiveProperties.maxActiveRecords := maxActiveRecords;
true;
};
case(#settleToRecords(settleToRecords)){
state.constants.archiveProperties.settleToRecords := settleToRecords;
true;
};
case(#maxRecordsInArchiveInstance(maxRecordsInArchiveInstance)){
state.constants.archiveProperties.maxRecordsInArchiveInstance := maxRecordsInArchiveInstance;
true;
};
case(#maxRecordsToArchive(maxRecordsToArchive)){
state.constants.archiveProperties.maxRecordsToArchive := maxRecordsToArchive;
true;
};
case(#maxArchivePages(maxArchivePages)){
state.constants.archiveProperties.maxArchivePages := maxArchivePages;
true;
};
case(#archiveIndexType(archiveIndexType)){
state.constants.archiveProperties.archiveIndexType := archiveIndexType;
true;
};
case(#archiveCycles(archiveCycles)){
state.constants.archiveProperties.archiveCycles := archiveCycles;
true;
};
case(#archiveControllers(archiveControllers)){
state.constants.archiveProperties.archiveControllers := archiveControllers;
true;
};
});
};
return Vec.toArray(results);
};



/// Runs the clean up process to move records to archive canisters
///
Expand Down
11 changes: 11 additions & 0 deletions src/migrations/v000_001_000/types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ module {

public type Transaction = Value;

public type UpdateSetting = {
#maxActiveRecords : Nat;
#settleToRecords : Nat;
#maxRecordsInArchiveInstance : Nat;
#maxRecordsToArchive : Nat;
#maxArchivePages : Nat;
#archiveIndexType : SW.IndexType;
#archiveCycles : Nat;
#archiveControllers : ??[Principal];
};

public type State = {
var ledger : Vec.Vector<Transaction>;
archives: Map.Map<Principal, TransactionRange>;
Expand Down

0 comments on commit df223cd

Please sign in to comment.