{"id":31915462,"url":"https://github.com/totalkrill/payeng","last_synced_at":"2026-06-29T21:31:13.013Z","repository":{"id":312335612,"uuid":"1047168221","full_name":"TotalKrill/payeng","owner":"TotalKrill","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-29T21:22:07.000Z","size":4902,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-27T03:27:59.648Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/TotalKrill.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T21:18:45.000Z","updated_at":"2025-08-29T21:22:11.000Z","dependencies_parsed_at":"2025-08-29T23:26:52.215Z","dependency_job_id":"59c3b42c-219c-407f-a371-712b81838b06","html_url":"https://github.com/TotalKrill/payeng","commit_stats":null,"previous_names":["totalkrill/payeng"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TotalKrill/payeng","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fpayeng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fpayeng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fpayeng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fpayeng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TotalKrill","download_url":"https://codeload.github.com/TotalKrill/payeng/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TotalKrill%2Fpayeng/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34944146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"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":[],"created_at":"2025-10-13T19:47:18.207Z","updated_at":"2026-06-29T21:31:12.994Z","avatar_url":"https://github.com/TotalKrill.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Toy Payment Engine\n\nA toy payment engine\n\n\n# Implmenentation\n\nDuring implementation of this paymenent engine, there was some confusions about the rules of chargebacks and such.\n\nThe assumption made is that a chargeback is something mandated, and not something that can be choosen to do.\nSo that can result in negative values on the account if there has been a chargeback after a withdrawal has been made...\n\nthe other way would have been to automatically refuse disputes on transactions that have had withdrawals after the disputed\ntransaction that if chargebacked would make the balance go below zero. \n\nThis payment engine does not allow withdrawal on locked accounts, but it allows for deposits on locked accounts, because its\nunclear what happened that allowed a deposit on a locked account, but at least with the money in our control, it can be\nverified better\n\nThe input is read in an iterator over a csv reader, so that the entire input is not held in ram at once, but handled one-by-one. The\nsolution still consumes quite a bit of ram since the transactions are held in ram under each account, so that disputes and such can be handled and checked.\nIt also checks for duplicate txid globally, to invalidate transactions that are reusing a txid. I chose to handle failed transactions (withdrawing to much)\nas a valid txid, but maybe only successfull transactions should be counted towards the used txid's.\n\nSome testdata was generated to see that it would handle larger datasets, its not very complete data, but at least it finished quite quickly\n\nThe fixed point implementation was done to avoid having any kind of rounding errors when doing the math.\n\nThe getters on the input struct is so that one should not be able to accidentally manipulate the input while handling it.\n\nGenerally I prefer to use type-safety for meanings of certain values, such as TxId(u32), and ClientId(u16), especially in larger\nsystems where there can be many of the same type, like different UUIDS or string identifiers of different types so that when going back to code, its easy to see which ID is expected\nwhere. But in this case, all the IDs were separate types anyway...\n\nAI usage has been quite low, mostly for generating the tests, and for small functions or methods that do specific usecases.\n\nhope any scrutinizing eyes enjoy it!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotalkrill%2Fpayeng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftotalkrill%2Fpayeng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftotalkrill%2Fpayeng/lists"}