/
apiBlock.go
118 lines (106 loc) · 5.62 KB
/
apiBlock.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package api
import (
"math/big"
"time"
"github.com/ME-MotherEarth/me-core/data/transaction"
)
// Block represents the structure for block that is returned by api routes
type Block struct {
Nonce uint64 `json:"nonce"`
Round uint64 `json:"round"`
Epoch uint32 `json:"epoch"`
Shard uint32 `json:"shard"`
NumTxs uint32 `json:"numTxs"`
Hash string `json:"hash"`
PrevBlockHash string `json:"prevBlockHash"`
StateRootHash string `json:"stateRootHash"`
AccumulatedFees string `json:"accumulatedFees,omitempty"`
DeveloperFees string `json:"developerFees,omitempty"`
AccumulatedFeesInEpoch string `json:"accumulatedFeesInEpoch,omitempty"`
DeveloperFeesInEpoch string `json:"developerFeesInEpoch,omitempty"`
Status string `json:"status,omitempty"`
Timestamp time.Duration `json:"timestamp,omitempty"`
NotarizedBlocks []*NotarizedBlock `json:"notarizedBlocks,omitempty"`
MiniBlocks []*MiniBlock `json:"miniBlocks,omitempty"`
EpochStartInfo *EpochStartInfo `json:"epochStartInfo,omitempty"`
EpochStartShardsData []*EpochStartShardData `json:"epochStartShardsData,omitempty"`
ScheduledData *ScheduledData `json:"scheduledData,omitempty"`
}
// ScheduledData is a structure that hold information about scheduled events
type ScheduledData struct {
ScheduledRootHash string `json:"rootHash,omitempty"`
ScheduledAccumulatedFees string `json:"accumulatedFees,omitempty"`
ScheduledDeveloperFees string `json:"developerFees,omitempty"`
ScheduledGasProvided uint64 `json:"gasProvided,omitempty"`
ScheduledGasPenalized uint64 `json:"penalized,omitempty"`
ScheduledGasRefunded uint64 `json:"gasRefunded,omitempty"`
}
// EpochStartInfo is a structure that holds information about epoch start meta block
type EpochStartInfo struct {
TotalSupply string `json:"totalSupply"`
TotalToDistribute string `json:"totalToDistribute"`
TotalNewlyMinted string `json:"totalNewlyMinted"`
RewardsPerBlock string `json:"rewardsPerBlock"`
RewardsForProtocolSustainability string `json:"rewardsForProtocolSustainability"`
NodePrice string `json:"nodePrice"`
PrevEpochStartRound uint64 `json:"prevEpochStartRound"`
PrevEpochStartHash string `json:"prevEpochStartHash"`
}
// NotarizedBlock represents a notarized block
type NotarizedBlock struct {
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
Round uint64 `json:"round"`
Shard uint32 `json:"shard"`
}
// EpochStartShardData is a structure that holds data about the epoch start shard data
type EpochStartShardData struct {
ShardID uint32 `json:"shard"`
Epoch uint32 `json:"epoch"`
Round uint64 `json:"round,omitempty"`
Nonce uint64 `json:"nonce,omitempty"`
HeaderHash string `json:"headerHash,omitempty"`
RootHash string `json:"rootHash,omitempty"`
ScheduledRootHash string `json:"scheduledRootHash,omitempty"`
FirstPendingMetaBlock string `json:"firstPendingMetaBlock,omitempty"`
LastFinishedMetaBlock string `json:"lastFinishedMetaBlock,omitempty"`
PendingMiniBlockHeaders []*MiniBlock `json:"pendingMiniBlockHeaders,omitempty"`
}
// MiniBlock represents the structure for a miniblock
type MiniBlock struct {
Hash string `json:"hash"`
Type string `json:"type"`
ProcessingType string `json:"processingType,omitempty"`
ConstructionState string `json:"constructionState,omitempty"`
IsFromReceiptsStorage bool `json:"isFromReceiptsStorage,omitempty"`
SourceShard uint32 `json:"sourceShard"`
DestinationShard uint32 `json:"destinationShard"`
Transactions []*transaction.ApiTransactionResult `json:"transactions,omitempty"`
Receipts []*transaction.ApiReceipt `json:"receipts,omitempty"`
IndexOfFirstTxProcessed int32 `json:"indexOfFirstTxProcessed"`
IndexOfLastTxProcessed int32 `json:"indexOfLastTxProcessed"`
}
// StakeValues is the structure that contains the total staked value and the total top up value
type StakeValues struct {
BaseStaked *big.Int
TopUp *big.Int
}
// DirectStakedValue holds the total staked value for an address
type DirectStakedValue struct {
Address string `json:"address"`
BaseStaked string `json:"baseStaked"`
TopUp string `json:"topUp"`
Total string `json:"total"`
}
// DelegatedValue holds the value and the delegation system SC address
type DelegatedValue struct {
DelegationScAddress string `json:"delegationScAddress"`
Value string `json:"value"`
}
// Delegator holds the delegator address and the slice of delegated values
type Delegator struct {
DelegatorAddress string `json:"delegatorAddress"`
DelegatedTo []*DelegatedValue `json:"delegatedTo"`
Total string `json:"total"`
TotalAsBigInt *big.Int `json:"-"`
}