mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 05:53:07 +00:00
Removed modules: - sales (including reservations, slot queue, marketplace abstractions, state machines, etc) - purchasing - erasure coding - contract interactions - prover - slot builder - block exchange payments - sales/purchasing from REST api - removed persistence command and all config params from cli configuration - CI workflows (devnet, dist tests, cirdl build, start eth node, contracts version reporting) - unused modules from tests - marketplace integration tests, and starting provider/validator/hardhat nodes - unused manifest properties - integration tests using the above # Conflicts: # .github/workflows/ci-reusable.yml # .github/workflows/docker.yml # build.nims # codex/blockexchange/engine/payments.nim # codex/codex.nim # codex/conf.nim # codex/contracts/Readme.md # codex/erasure.nim # codex/erasure/backend.nim # codex/erasure/backends/leopard.nim # codex/erasure/erasure.nim # codex/rest/api.nim # codex/sales.nim # codex/sales/reservations.nim # codex/sales/states/filled.nim # codex/sales/states/preparing.nim # codex/sales/states/provingsimulated.nim # codex/slots/builder/builder.nim # codex/slots/converters.nim # codex/slots/proofs/backends/circomcompat.nim # codex/slots/proofs/backends/converters.nim # codex/slots/proofs/prover.nim # codex/slots/sampler/sampler.nim # codex/slots/sampler/utils.nim # codex/slots/types.nim # tests/integration/5_minutes/testrestapivalidation.nim # tests/integration/hardhatprocess.nim # tests/integration/multinodes.nim # tools/cirdl/cirdl.nim
79 lines
2.1 KiB
Nim
79 lines
2.1 KiB
Nim
import pkg/questionable
|
|
import pkg/stew/byteutils
|
|
import pkg/libp2p
|
|
import pkg/codexdht/discv5/node as dn
|
|
import pkg/codexdht/discv5/routing_table as rt
|
|
import ../utils/json
|
|
import ../manifest
|
|
import ../units
|
|
|
|
export json
|
|
|
|
type
|
|
|
|
RestContent* = object
|
|
cid* {.serialize.}: Cid
|
|
manifest* {.serialize.}: Manifest
|
|
|
|
RestContentList* = object
|
|
content* {.serialize.}: seq[RestContent]
|
|
|
|
RestNode* = object
|
|
nodeId* {.serialize.}: RestNodeId
|
|
peerId* {.serialize.}: PeerId
|
|
record* {.serialize.}: SignedPeerRecord
|
|
address* {.serialize.}: Option[dn.Address]
|
|
seen* {.serialize.}: bool
|
|
|
|
RestRoutingTable* = object
|
|
localNode* {.serialize.}: RestNode
|
|
nodes* {.serialize.}: seq[RestNode]
|
|
|
|
RestPeerRecord* = object
|
|
peerId* {.serialize.}: PeerId
|
|
seqNo* {.serialize.}: uint64
|
|
addresses* {.serialize.}: seq[AddressInfo]
|
|
|
|
RestNodeId* = object
|
|
id*: NodeId
|
|
|
|
RestRepoStore* = object
|
|
totalBlocks* {.serialize.}: Natural
|
|
quotaMaxBytes* {.serialize.}: NBytes
|
|
quotaUsedBytes* {.serialize.}: NBytes
|
|
quotaReservedBytes* {.serialize.}: NBytes
|
|
|
|
proc init*(_: type RestContentList, content: seq[RestContent]): RestContentList =
|
|
RestContentList(content: content)
|
|
|
|
proc init*(_: type RestContent, cid: Cid, manifest: Manifest): RestContent =
|
|
RestContent(cid: cid, manifest: manifest)
|
|
|
|
proc init*(_: type RestNode, node: dn.Node): RestNode =
|
|
RestNode(
|
|
nodeId: RestNodeId.init(node.id),
|
|
peerId: node.record.data.peerId,
|
|
record: node.record,
|
|
address: node.address,
|
|
seen: node.seen > 0.5,
|
|
)
|
|
|
|
proc init*(_: type RestRoutingTable, routingTable: rt.RoutingTable): RestRoutingTable =
|
|
var nodes: seq[RestNode] = @[]
|
|
for bucket in routingTable.buckets:
|
|
for node in bucket.nodes:
|
|
nodes.add(RestNode.init(node))
|
|
|
|
RestRoutingTable(localNode: RestNode.init(routingTable.localNode), nodes: nodes)
|
|
|
|
proc init*(_: type RestPeerRecord, peerRecord: PeerRecord): RestPeerRecord =
|
|
RestPeerRecord(
|
|
peerId: peerRecord.peerId, seqNo: peerRecord.seqNo, addresses: peerRecord.addresses
|
|
)
|
|
|
|
proc init*(_: type RestNodeId, id: NodeId): RestNodeId =
|
|
RestNodeId(id: id)
|
|
|
|
proc `%`*(obj: RestNodeId): JsonNode =
|
|
% $obj.id
|