-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fee per gram stats to ffi library
- Loading branch information
Showing
11 changed files
with
4,297 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2022 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
const InterfaceFFI = require("./ffiInterface"); | ||
|
||
class FeePerGramStat { | ||
ptr; | ||
|
||
pointerAssign(ptr) { | ||
if (this.ptr) { | ||
this.destroy(); | ||
this.ptr = ptr; | ||
} else { | ||
this.ptr = ptr; | ||
} | ||
} | ||
|
||
getPtr() { | ||
return this.ptr; | ||
} | ||
|
||
getOrder() { | ||
return InterfaceFFI.feePerGramStatGetOrder(this.ptr); | ||
} | ||
|
||
getMinFeePerGram() { | ||
return InterfaceFFI.feePerGramStatGetMinFeePerGram(this.ptr); | ||
} | ||
|
||
getAvgFeePerGram() { | ||
return InterfaceFFI.feePerGramStatGetAvgFeePerGram(this.ptr); | ||
} | ||
|
||
getMaxFeePerGram() { | ||
return InterfaceFFI.feePerGramStatGetMaxFeePerGram(this.ptr); | ||
} | ||
|
||
destroy() { | ||
if (this.ptr) { | ||
InterfaceFFI.feePerGramStatDestroy(this.ptr); | ||
this.ptr = undefined; //prevent double free segfault | ||
} | ||
} | ||
} | ||
|
||
module.exports = FeePerGramStat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2022 The Tari Project | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
const FeePerGramStat = require("./FeePerGramStat"); | ||
const InterfaceFFI = require("./ffiInterface"); | ||
|
||
class FeePerGramStats { | ||
ptr; | ||
|
||
constructor(ptr) { | ||
this.ptr = ptr; | ||
} | ||
|
||
getLength() { | ||
return InterfaceFFI.feePerGramStatsGetLength(this.ptr); | ||
} | ||
|
||
getAt(position) { | ||
let result = new FeePerGramStat(); | ||
result.pointerAssign(InterfaceFFI.feePerGramStatsGetAt(this.ptr, position)); | ||
return result; | ||
} | ||
|
||
destroy() { | ||
if (this.ptr) { | ||
InterfaceFFI.feePerGramStatsDestroy(this.ptr); | ||
this.ptr = undefined; //prevent double free segfault | ||
} | ||
} | ||
} | ||
|
||
module.exports = FeePerGramStats; |
Oops, something went wrong.