Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ option(BUILD_BENCHMARK "Build the EFI benchmark application" OFF)
option(BUILD_BINARY "Build the EFI application" ON)
option(USE_SANITIZER "Build test with sanitizer support (clang only)" ON)
option(LITE_WASM_SC "Enable testnet-lite-RAM Wasm smart contracts" OFF)
option(ANT_WALKER "Build the ant-colony walker sidecar and its node client" ON)
set(QUBIC_STANDALONE_RELEASE ON CACHE INTERNAL "Standalone builds are the only supported configuration" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static dependencies" FORCE)
set(OPENSSL_USE_STATIC_LIBS TRUE CACHE BOOL "Use static OpenSSL" FORCE)
Expand Down
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ if(IS_CLANG)
endif()
target_link_libraries(qubic-cli PRIVATE m)

if(ANT_WALKER)
target_compile_definitions(Qubic PRIVATE ANT_WALKER)
endif()

# Configure linker settings based on compiler
if(IS_MSVC)
if(NOT LITE_WASM_SC)
Expand Down
43 changes: 43 additions & 0 deletions src/extensions/ant_colony_maintenance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#pragma once

// Colony upkeep outside consensus. Pure functions of a colony, so they are testable without a node.

namespace AntColonyMaintenance
{
// fork() clones only the calling thread, so a promoted child can inherit a claim with no owner and
// ensureAntRecordAnn's waiter would spin on it forever.
inline unsigned int releaseInheritedClaims(AntColonyBpp9000T& colony)
{
unsigned int released = 0;
const unsigned int recordCount = colony.solutionCount();
for (unsigned int index = 0; index < recordCount; index++)
{
if (colony.isAnnClaimHeld(index))
{
colony.releaseAnnClaim(index);
released++;
}
}
return released;
}

// A rebuild starts from the parent's network, so a record whose parent has none cannot be taken.
inline bool isRebuildableNow(AntColonyBpp9000T& colony, unsigned int index)
{
if (colony.isAnnMaterialised(index) || colony.isAnnClaimHeld(index))
{
return false;
}
const AntSolutionRecord* record = colony.recordAt(index);
if (record == nullptr)
{
return false;
}
if (record->parentRef.isRoot())
{
return true;
}
const long long parentIndex = colony.findIndexBySolutionRef(record->parentRef);
return parentIndex != ANT_INVALID_INDEX && colony.isAnnMaterialised((unsigned int)parentIndex);
}
}
Loading
Loading