Socket
Book a DemoInstallSign in
Socket

github.com/pbreedt/fingerprintjs

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/pbreedt/fingerprintjs

Source
Go
Version
v0.0.0-20220502210141-5e29fed89d7d
Version published
Created
Source

FingerprintJS

A take-home assignment for FingerprintJS.

General info

This project takes two files as input:

  • ./input/api_latencies.json: contains latency data for country codes
  • ./input/transactions.csv: contains the transaction data for processing

The aim it to maximize the transaction value that is being processed in a given time.

Technologies

  • Go - version 1.17

Getting started

First get the source code by cloning the repository from GitHub:

git clone https://github.com/pbreedt/fingerprintjs.git

...and change into the newly created directory.

Then, either build the app:

go build

...or run it straight from source code:

go run . 1000

Usage:

./fingerprintjs timeLimit [latency file] [transactions file]  
        timeLimit               - number of total time allowed for processing  
        latency file            - path to the latency JSON file (optional: default to ./input/api_latencies.json)  
        transactions file       - path to the transactions CSV file (optional: default to ./input/transactions.csv)  

Questions & answers:

The question that was posted was:

What is the max USD value that can be processed in 50ms, 60ms, 90ms, 1000ms?

My findings are as follows:

Time frame (ms)Total ValueNew TotalActual ms
503637.984139.43(50)
604362.014624.86(56)
906870.486972.29(90)
100035471.8135471.81(1000)

The algorithm

The basic principle is to calculate the 'value per second' for each transaction. This is, the USD value that will be processed for every 1s spend processing the particular transaction.

Next, I sort all the transactions according to the 'value per second' values, with the highest amounts taking preference if any two transactions have the same 'value per second'.

IMPROVEMENT:
Keep track of the time difference between processing time and total available time. Try and fill this time a little bit better.

General code

I tried to stay as close as possible to the originally provided function signatures, thus keeping the same input and return parameters.

Various 'debug' output lines have been commented out, but left in the code.

Some unit tests are included to check for predictable results for controlled input.

Contact

Thank you for the opportunity, I had fun doing this assignment!

Written by @pbreedt

FAQs

Package last updated on 02 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.