forked from FactomProject/factomd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.go
73 lines (67 loc) · 2.64 KB
/
block.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
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package interfaces
type IFBlock interface {
BinaryMarshallable
Printable
GetHash() IHash // Returns the hash of the object
//DatabaseBlockWithEntries
GetDatabaseHeight() uint32
DatabasePrimaryIndex() IHash //block.KeyMR()
DatabaseSecondaryIndex() IHash //block.GetHash()
New() BinaryMarshallableAndCopyable
GetEntryHashes() []IHash
GetEntrySigHashes() []IHash
GetTransactionByHash(hash IHash) ITransaction
// Get the ChainID. This is a constant for all Factoids.
GetChainID() IHash
// Validation functions
Validate() error
ValidateTransaction(int, ITransaction) error
// Marshal just the header for the block. This is to include the header
// in the FullHash
MarshalHeader() ([]byte, error)
// Marshal just the transactions. This is because we need the length
MarshalTrans() ([]byte, error)
// Add a coinbase transaction. This transaction has no inputs
AddCoinbase(ITransaction) error
// Add a proper transaction. Transactions are validated before
// being added to the block.
AddTransaction(ITransaction) error
// Calculate all the MR and serial hashes for this block. Done just
// prior to being persisted.
CalculateHashes()
// Hash accessors
// Get Key MR() hashes the header with the GetBodyMR() of the transactions
GetKeyMR() IHash
// Get the MR for the list of transactions
GetBodyMR() IHash
// Get the KeyMR of the previous block.
GetPrevKeyMR() IHash
SetPrevKeyMR(IHash)
GetLedgerKeyMR() IHash
GetPrevLedgerKeyMR() IHash
SetPrevLedgerKeyMR(IHash)
// Accessors for the Directory Block Height
SetDBHeight(uint32)
GetDBHeight() uint32
// Accessors for the Exchange rate
SetExchRate(uint64)
GetExchRate() uint64
// Accessors for the transactions
GetTransactions() []ITransaction
// Mark an end of Minute. If there are multiple calls with the same minute value
// the later one simply overwrites the previous one. Since this is an informational
// data point, we do not enforce much, other than order (the end of period one can't
// come before period 2. We just adjust the periods accordingly.
EndOfPeriod(min int)
GetEndOfPeriod() [10]int
// Returns the milliTimestamp of the coinbase transaction. This is used to validate
// the timestamps of transactions included in the block. Transactions prior to the
// TRANSACTION_PRIOR_LIMIT or after the TRANSACTION_POST_LIMIT are considered invalid
// for this block. -1 is returned if no coinbase transaction is found.
GetCoinbaseTimestamp() Timestamp
GetNewInstance() IFBlock // Get a new instance of this object
IsSameAs(IFBlock) bool
}