Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(p2p): add reputation events (#470)
This commit implements reputation events as described in issue #457. Those events track the history of the behaviour of a node and are stored in the database.
- Loading branch information
1 parent
3f6f11e
commit 9f8ab32
Showing
9 changed files
with
181 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Sequelize from 'sequelize'; | ||
import { db } from '../../types'; | ||
|
||
export default (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) => { | ||
const attributes: db.SequelizeAttributes<db.ReputationEventAttributes> = { | ||
id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, | ||
event: { type: DataTypes.INTEGER, allowNull: false }, | ||
nodeId: { type: DataTypes.INTEGER, allowNull: false }, | ||
}; | ||
|
||
const options: Sequelize.DefineOptions<db.ReputationEventInstance> = { | ||
tableName: 'reputationEvents', | ||
timestamps: true, | ||
updatedAt: false, | ||
}; | ||
|
||
const ReputationEvent = sequelize.define<db.ReputationEventInstance, db.ReputationEventAttributes>('ReputationEvent', attributes, options); | ||
|
||
ReputationEvent.associate = (models: Sequelize.Models) => { | ||
models.ReputationEvent.belongsTo(models.Node, { | ||
foreignKey: 'nodeId', | ||
}); | ||
}; | ||
|
||
return ReputationEvent; | ||
}; |
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
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