{"id":22177447,"url":"https://github.com/r3code/hlf-queue-example","last_synced_at":"2025-08-04T07:11:27.948Z","repository":{"id":150686099,"uuid":"263249406","full_name":"r3code/hlf-queue-example","owner":"r3code","description":"An example of Hyperledger Fabric Chaincode implementing FIFO Queue","archived":false,"fork":false,"pushed_at":"2020-05-28T19:20:42.000Z","size":203,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T18:28:25.440Z","etag":null,"topics":["cckit","chaincode","fifo-queue","golang","hlf","hyperledger","hyperledger-fabric","smart-contracts"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r3code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-12T06:12:35.000Z","updated_at":"2020-05-28T19:20:45.000Z","dependencies_parsed_at":"2023-04-10T01:31:50.520Z","dependency_job_id":null,"html_url":"https://github.com/r3code/hlf-queue-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/r3code/hlf-queue-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r3code%2Fhlf-queue-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r3code%2Fhlf-queue-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r3code%2Fhlf-queue-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r3code%2Fhlf-queue-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r3code","download_url":"https://codeload.github.com/r3code/hlf-queue-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r3code%2Fhlf-queue-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268660199,"owners_count":24286029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cckit","chaincode","fifo-queue","golang","hlf","hyperledger","hyperledger-fabric","smart-contracts"],"created_at":"2024-12-02T08:28:22.218Z","updated_at":"2025-08-04T07:11:27.924Z","avatar_url":"https://github.com/r3code.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FIFO Queue Hyperledger Fabric chaincode\n\n[![Build Status](https://travis-ci.com/r3code/hlf-queue-example.svg?branch=master)](https://travis-ci.com/r3code/hlf-queue-example)\n\nHLFQueue chaincode stores and manages a FIFO queue.\nThe code based on `cckit` framework which supports only Hyperledger 1.4.\n\n## Supported chaincode methods\n\n**Push** - adds an item data to the tail of the queue and returns created queue item. ID of the item generated automatically as ULID (see https://github.com/oklog/ulid).\n\n**Pop** - dequeues (extracts) an item from the head of the queue. If queue is empty it will raise an error \"Empty queue\".\n\n**Select** - allows you to filter queue items using a query string in `expr` syntax (see https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md). Returns a list of matched queue items. Example query `{.Amount \u003e 1 and .Amount \u003c 4}` - select items where `Amount` between 1 and 4.\n\n**ListItems** - returns a list of all item in queue.\n\n**Attach Data** - attaches specified `[]byte` data to an item `ExtraData` specified by `ID` (ULID string). Replaces existing item `ExtraData`.\n\n**MoveAfter** - cuts the item and puts it after the specified item ID in the queue.\n\n**MoveBefore** - cuts the item and puts it before the specified item ID in the queue.\n\n\n## Building\n\n### Dependencies \n\nSee https://github.com/SAPDocuments/Tutorials/issues/4415\n\n\tgo get github.com/hyperledger/fabric-chaincode-go/shim\n\tgo get github.com/hyperledger/fabric/core/peer\n\tgo get github.com/hyperledger/fabric/common/util\n\n\n### Fix Docker package error at Windows\n\n`C:\\Users\\r3code\\go\\pkg\\mod\\github.com\\docker\\docker@v1.4.2-0.20191101170500-ac7306503d23\\pkg\\system\\filesys_windows.go:112:24: cannot use uintptr(unsafe.Pointer(\u0026sd[0])) (type uintptr) as type *\"golang.org/x/sys/windows\".SECURITY_DESCRIPTOR in assignment`\n\nInstall a package:\n\n\tgo get github.com/docker/docker@2200d938a2d5e7cd7437489c22a32d37d9bb380d\n\n\n### Fix build errors\n\nReplace in file paths a `shim`-path to \n\n\t\"github.com/hyperledger/fabric-chaincode-go/shim\"\n\nbecause hyperledger API path has changed.\n\n## Build and start the chaincode\n\nFirst - start network.\n\n### Install the chaincode \n\n\tdocker exec -it chaincode bash\n\t// output: root@d2629980e76b:/opt/gopath/src/chaincode\n\n**Сompile the chaincode**\n\n\tcd ./hlf-queue-example/cmd/hlfqueue\n\tgo build\n\n**Run the chaincode**\n\n\tCORE_PEER_ADDRESS=peer:7052 CORE_CHAINCODE_ID_NAME=mycc:0 ./hlfqueue\n\nThe chaincode is started with peer and chaincode logs indicating successful registration with the peer.\n\n**Prepare to use**\n\n\tdocker exec -it cli bash\n\tpeer chaincode install -p chaincodedev/chaincode/hlf-queue-example/cmd/hlfqueue -n mycc -v 0\n\tpeer chaincode instantiate -n mycc -v 0 -c '{\"Args\":[]}' -C mychannel\n\n`Instantinate` will init the ledger default states used by the chaincode.\n\n\n### Push an item to the queue\n\nPush an item with data:\n\n\t{\n\t\t\"from\": \"A\",\n\t\t\"to\": \"B\",\n\t\t\"amount\": 1\n\t}\n\nExecute a command:\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"Push\", \"{\\\"From\\\":\\\"A\\\",\\\"To\\\":\\\"B\\\", \\\"Amount\\\": 1 }\"]}' -C myc\n\nPush an item with extra data:\n\n\t{\n\t\t\"From\": \"A\",\n\t\t\"To\": \"B\",\n\t\t\"Amount\": 1,\n\t\t\"ExtraData\": \"A to B\"\n\t}\n\nExecute a command:\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"Push\", \"{\\\"From\\\":\\\"A\\\",\\\"To\\\":\\\"B\\\", \\\"Amount\\\": 1, \\\"ExtraData\\\": \\\"A to B\\\" }\"]}' -C myc\n\n### Pop an item from the queue\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"Pop\"]}' -C myc\n\n### Reordering queue items\n\n#### Move after\n\nCut the item with ID `01D78XYFJ1PRM1WPBCBT3VITEM` and put after `01D78XYFJ1PRM1WPBCBT3AFTER`.\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"MoveAfter\", \"01D78XYFJ1PRM1WPBCBT3VITEM\", \"01D78XYFJ1PRM1WPBCBT3AFTER\"]}' -C myc\n\n#### Move before\n\nCut the item with ID `01D78XYFJ1PRM1WPBCBT3VHOER` and put before `01D78XYFJ1PRM1WPBCBT3VHMNV`.\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"MoveBefore\", \"01D78XYFJ1PRM1WPBCBT3VHOER\", \"01D78XYFJ1PRM1WPBCBT3VHMNV\"]}' -C myc\n\n### Select queue items (filtering)\n\nSelect all items where `From = \"A\"` and `Amount \u003e 2`\n\n\tpeer chaincode query -n mycc -c '{\"Args\":[\"Select\", \"{.From == \\\"A\\\" and .Amount \u003e 2 }\"]}' -C myc\n\n### Attach data\tto an item with specified ID\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"AttachData\", \"01D78XYFJ1PRM1WPBCBT3VHMNV\", \"Data to attach\"]}' -C myc\n\n### Extra \n\n#### List queue items\n\n\tpeer chaincode invoke -n mycc -c '{\"Args\":[\"ListItems\"]}' -C myc\n\n\n## Development\n\n### Testing \n\nTo run tests call:\n\n\tgo test\n\n### Debugging \n\nSet `CORE_CHAINCODE_LOGGING_LEVEL=debug` to see a debug output.\nIf you want to add your own Debug messages use `c.Logger().Debug(msg)`\n\nIn Windows PowerShell:\n\n\t$env:CORE_CHAINCODE_LOGGING_LEVEL=debug\n\tgo test // will output \"DEBU\" prefixed messaged to STDOUT\n\nIn Linux:\n\n\t$CORE_CHAINCODE_LOGGING_LEVEL=debug\n\tgo test // will output \"DEBU\" prefixed messaged to STDOUT\n\n\n\t\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr3code%2Fhlf-queue-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr3code%2Fhlf-queue-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr3code%2Fhlf-queue-example/lists"}