Compare commits

..
11 Commits
Author SHA1 Message Date
Chris Troutner b8c1156de7 Merge pull request #72 from Permissionless-Software-Foundation/ct-unstable
Adding debugging to usage tracking
2025-05-18 15:40:31 -07:00
Chris Troutner 5146155555 Merge remote-tracking branch 'upstream/master' into ct-unstable 2025-05-18 15:38:43 -07:00
Chris Troutner af83c06b43 Merge pull request #174 from Permissionless-Software-Foundation/ct-unstable
fix(usage): Debugging issue with usage tracking
2025-05-18 15:37:46 -07:00
Chris Troutner e6317c3282 fix(usage): Debugging issue with usage tracking 2025-05-18 15:36:32 -07:00
Chris Troutner 354321c956 Merge pull request #173 from Permissionless-Software-Foundation/ct-unstable
fix(wallet.adapter): Binding this object to all methods
2025-04-22 19:07:06 -07:00
Chris Troutner af2572a493 fix(wallet.adapter): Binding this object to all methods 2025-04-22 18:58:03 -07:00
Chris Troutner ac451fd601 Merge pull request #71 from Permissionless-Software-Foundation/ct-unstable
Passing pagination paramter through to PSFFPP
2025-04-16 07:38:00 -07:00
Chris Troutner 6857fe0166 linting 2025-04-16 07:29:40 -07:00
Chris Troutner 89a03e561a feat(GET /pins/:page): Adding pagenation to endpoint 2025-04-16 07:29:27 -07:00
Chris Troutner 22e32a6fc1 Merge pull request #70 from Permissionless-Software-Foundation/ct-unstable
fix(psffpp): Updating to psffpp v1.2.0
2025-04-12 21:05:52 -07:00
Chris Troutner fcf5db7fa4 fix(psffpp): Updating to psffpp v1.2.0 2025-04-12 21:04:17 -07:00
11 changed files with 45 additions and 21 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"password": "BJdugaoiq10ZJnA7Uskd",
"password": "YsFhsCVCqussWyyLYUjM",
"email": "system@system.com",
"id": "67c114fd4935ba05e48f6bb2",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3YzExNGZkNDkzNWJhMDVlNDhmNmJiMiIsImlhdCI6MTc0MDcwNzA2OX0.R5nU8J5yhGorp7I5kc8_dRESbo4hwCIrTtqJiVYVhLA"
"id": "67ffbea61a8de3388f82c401",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY3ZmZiZWE2MWE4ZGUzMzg4ZjgyYzQwMSIsImlhdCI6MTc0NDgxMzczNH0.a4wM-CfGudF40yi4lwTsnd_aDZHrRn87zjHYxFZmeC4"
}
+8 -8
View File
@@ -53,7 +53,7 @@
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
"nodemailer": "6.7.5",
"passport-local": "1.0.0",
"psffpp": "1.1.9",
"psffpp": "1.2.0",
"public-ip": "6.0.1",
"semver": "7.3.5",
"winston": "3.3.3",
@@ -19902,9 +19902,9 @@
"license": "MIT"
},
"node_modules/psf-multisig-approval": {
"version": "2.0.7",
"resolved": "http://94.130.170.209:4873/psf-multisig-approval/-/psf-multisig-approval-2.0.7.tgz",
"integrity": "sha512-Z00+ozZ3LqBL/5naimg9r15FfPZk01nzNe/YaKGNs4AE8szVK4PxwMTq1su3h4QFHWgDIBth+sbxgJCguy5qzw==",
"version": "2.1.0",
"resolved": "http://94.130.170.209:4873/psf-multisig-approval/-/psf-multisig-approval-2.1.0.tgz",
"integrity": "sha512-QLlOnYzeOx6OQXu5MGRlSP/IhS+X1Y7v3WxUse9riqYHOvvz3WeUPZUB8TVnSsUR6lH5W8Ckshl1lnaWXcPs7Q==",
"license": "MIT",
"dependencies": {
"@chris.troutner/bitcore-lib-cash": "8.25.26",
@@ -19923,13 +19923,13 @@
}
},
"node_modules/psffpp": {
"version": "1.1.9",
"resolved": "http://94.130.170.209:4873/psffpp/-/psffpp-1.1.9.tgz",
"integrity": "sha512-9DKlU+PbwcXLqoq18iOt8Wr6HDVAQqvrW71gNKmJ/1ZK7Tv0bgjxt6agRZAKuj0zDRUH7nPqvcqCs8OqEQ1biQ==",
"version": "1.2.0",
"resolved": "http://94.130.170.209:4873/psffpp/-/psffpp-1.2.0.tgz",
"integrity": "sha512-F3KDh6pzI5ZRxkek6KWFpwIcgx9tocnAKJie0HwNwTBuuS40/LsUnkmhVMghufF603Fp0vO6o3P4vgbTTzw6pg==",
"license": "MIT",
"dependencies": {
"axios": "1.3.5",
"psf-multisig-approval": "2.0.7"
"psf-multisig-approval": "2.1.0"
}
},
"node_modules/psffpp/node_modules/axios": {
+1 -1
View File
@@ -68,7 +68,7 @@
"node-fetch": "npm:@achingbrain/node-fetch@2.6.7",
"nodemailer": "6.7.5",
"passport-local": "1.0.0",
"psffpp": "1.1.9",
"psffpp": "1.2.0",
"public-ip": "6.0.1",
"semver": "7.3.5",
"winston": "3.3.3",
+4 -1
View File
@@ -191,8 +191,11 @@ class IpfsFilesAdapter {
throw new Error('No IPFS File Pin Service provider available yet.')
}
const { page } = inObj
const rpcData = {
endpoint: 'getPins'
endpoint: 'getPins',
page
}
// Generate a UUID for the call.
+7
View File
@@ -20,6 +20,13 @@ class Wallet {
// Bind 'this' object to all subfunctions
this.instanceWalletWithoutInitialization = this.instanceWalletWithoutInitialization.bind(this)
this._instanceWallet = this._instanceWallet.bind(this)
this.openWallet = this.openWallet.bind(this)
this.instanceWallet = this.instanceWallet.bind(this)
this.incrementNextAddress = this.incrementNextAddress.bind(this)
this.getKeyPair = this.getKeyPair.bind(this)
this.optimize = this.optimize.bind(this)
this.getBalance = this.getBalance.bind(this)
}
// This is used for initializing the wallet, without waiting to update the wallet
+2 -2
View File
@@ -262,11 +262,11 @@ class IpfsRESTControllerLib {
*/
async getPins (ctx) {
try {
// const { cid } = ctx.params
const { page } = ctx.params
const ipfsFiles = this.adapters.ipfsFiles
const pinData = await ipfsFiles.getPins()
const pinData = await ipfsFiles.getPins({ page })
console.log('getPins() pinData: ', pinData)
ctx.body = pinData
+1 -1
View File
@@ -60,7 +60,7 @@ class IpfsRouter {
this.router.get('/download/:cid', this.ipfsRESTController.downloadFile)
this.router.get('/service', this.ipfsRESTController.getService)
this.router.get('/file-info/:cid', this.ipfsRESTController.getFileInfo)
this.router.get('/pins', this.ipfsRESTController.getPins)
this.router.get('/pins/:page', this.ipfsRESTController.getPins)
this.router.get('/cid2json/:cid', this.ipfsRESTController.cid2json)
this.router.post('/pin-claim', this.ipfsRESTController.pinClaim)
// Attach the Controller routes to the Koa app.
+5 -2
View File
@@ -1,6 +1,6 @@
/*
This Controller library is concerned with timer-based functions that are
kicked off periodicially.
kicked off periodically.
*/
import config from '../../config/index.js'
@@ -45,7 +45,7 @@ class TimerControllers {
stopTimers () {
clearInterval(this.optimizeWalletHandle)
clearInterval(this.cleanusageHandle)
clearInterval(this.cleanUsageHandle)
}
// Replace this example function with your own timer handler.
@@ -67,6 +67,9 @@ class TimerControllers {
// Clean the usage state so that stats reflect the last 24 hours.
cleanUsage () {
try {
const now = new Date()
console.log(`cleanUsage() Timer Controller executing at ${now.toLocaleString()}`)
this.useCases.usage.cleanUsage()
return true
+4
View File
@@ -36,7 +36,11 @@ class UsageUseCases {
const now = new Date()
const twentyFourHoursAgo = now.getTime() - (60000 * 60 * 24)
console.log('cleanUsage() now: ', now)
console.log('cleanUsage() restCalls.length before filtering: ', restCalls.length)
restCalls = restCalls.filter(x => x.timestamp > twentyFourHoursAgo)
console.log('cleanUsage() restCalls.length after filtering: ', restCalls.length)
return restCalls
} catch (err) {
console.error('Error in usage-use-cases.js/cleanUsage()')
@@ -400,12 +400,14 @@ describe('#IPFS REST API', () => {
assert.isTrue(ctx.body.success)
})
})
describe('#getPins', () => {
it('should return 422 status on biz logic error', async () => {
try {
sandbox.stub(uut.adapters.ipfsFiles, 'getPins').throws(new Error('test error'))
ctx.request.body = {}
ctx.params = { page: 1 }
await uut.getPins(ctx)
@@ -421,12 +423,14 @@ describe('#IPFS REST API', () => {
sandbox.stub(uut.adapters.ipfsFiles, 'getPins').resolves({ success: true })
ctx.request.body = {}
ctx.params = { page: 1 }
await uut.getPins(ctx)
assert.isTrue(ctx.body.success)
})
})
describe('#cid2json', () => {
it('should return 422 status on biz logic error', async () => {
try {
+6 -3
View File
@@ -1,6 +1,5 @@
/*
Unit tests for the use-cases/usage-use-cases.js business logic library.
Unit tests for the use-cases/usage-use-cases.js business logic library.
*/
// Public npm libraries
@@ -58,7 +57,7 @@ describe('#usage-use-case', () => {
// set older mock data
restCalls.push({
timestamp: now.getTime() - (60000 * 60 * 24),
timestamp: now.getTime() - (60000 * 60 * 48), // 48 hours ago
ip: '127.0.0.1'
})
@@ -88,6 +87,7 @@ describe('#usage-use-case', () => {
}
})
})
describe('#getRestSummary', () => {
it('should get the number of rest calls', () => {
// Set mock data
@@ -137,6 +137,7 @@ describe('#usage-use-case', () => {
assert.equal(result[0].ip, 'localhost')
assert.equal(result[0].cnt, '2')
})
it('should return a maximum of 20 values', () => {
// Fill Array with 21 values
for (let i = 0; i < 21; i++) {
@@ -154,6 +155,7 @@ describe('#usage-use-case', () => {
assert.equal(result.length, 20)
})
it('should handle error', () => {
try {
// Set mock data
@@ -194,6 +196,7 @@ describe('#usage-use-case', () => {
assert.equal(result[0].endpoint, 'GET /api/v1/users')
assert.equal(result[0].cnt, '2')
})
it('should return a maximum of 20 values', () => {
// Fill Array with 21 values
for (let i = 0; i < 21; i++) {