-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorphaned_block.go
More file actions
35 lines (31 loc) · 1.32 KB
/
orphaned_block.go
File metadata and controls
35 lines (31 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package models
import "github.com/jackc/pgtype"
type OrphanedBlock struct {
Hash string `json:"hash" gorm:"primaryKey"`
Size uint64 `json:"size"`
// Header fields
ParentHash string `json:"parent_hash"`
UncleHash string `json:"uncle_hash"`
Coinbase string `json:"coinbase"`
Root string `json:"root"`
TxHash string `json:"tx_hash"`
ReceiptHash string `json:"receipt_hash"`
Bloom []byte `json:"bloom"`
Difficulty pgtype.Numeric `json:"difficulty" gorm:"type:numeric"`
Number pgtype.Numeric `json:"number" gorm:"type:numeric"`
GasLimit uint64 `json:"gas_limit"`
GasUsed uint64 `json:"gas_used"`
Time uint64 `json:"time"`
Extra []byte `json:"extra"`
MixDigest string `json:"mix_digest"`
Nonce pgtype.Numeric `json:"nonce" gorm:"type:numeric"`
BaseFee pgtype.Numeric `json:"base_fee" gorm:"type:numeric"`
}
func (db *DB) GetOrphanedBlockByHash(orphanedBlockHash string) (*OrphanedBlock, error) {
var orphanedBlock OrphanedBlock
return &orphanedBlock, db.Where("hash = ?", orphanedBlockHash).First(&orphanedBlock).Error
}
func (db *DB) GetAllOrphanedBlocks() ([]OrphanedBlock, error) {
var orphanedBlocks []OrphanedBlock
return orphanedBlocks, db.Find(&orphanedBlocks).Error
}