feat: Initial release (1.0)
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
c318df8bf3
commit
f51679193a
16 changed files with 956 additions and 0 deletions
45
pool.go
Normal file
45
pool.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Pool to store pool attributes
|
||||
type Pool struct {
|
||||
gorm.Model
|
||||
Coin string `gorm:"unique;not null"`
|
||||
LastBlockNumber float64
|
||||
}
|
||||
|
||||
// NewPool creates a Pool
|
||||
func NewPool(coin string) *Pool {
|
||||
return &Pool{Coin: coin}
|
||||
}
|
||||
|
||||
// String represents Pool to a printable format
|
||||
func (p *Pool) String() string {
|
||||
return fmt.Sprintf("Pool<%s>", p.Coin)
|
||||
}
|
||||
|
||||
// Block to store block attributes
|
||||
type Block struct {
|
||||
Hash string `gorm:"unique;not null"`
|
||||
Number float64 `gorm:"not null"`
|
||||
Reward float64 `gorm:"not null"`
|
||||
}
|
||||
|
||||
// NewBlock creates a Block
|
||||
func NewBlock(hash string, number float64, reward float64) *Block {
|
||||
return &Block{
|
||||
Hash: hash,
|
||||
Number: number,
|
||||
Reward: reward,
|
||||
}
|
||||
}
|
||||
|
||||
// String represents Block to a printable format
|
||||
func (b *Block) String() string {
|
||||
return fmt.Sprintf("Block<%.0f>", b.Number)
|
||||
}
|
Reference in a new issue