github.com/annchain/OG@v0.0.9/og/types/tx_interface.go (about) 1 package types 2 3 import ( 4 "github.com/annchain/OG/arefactor/og/types" 5 "github.com/annchain/OG/common" 6 ) 7 8 type TxBaseType uint8 9 10 const ( 11 TxBaseTypeTx TxBaseType = iota 12 TxBaseTypeSequencer 13 ) 14 15 // Txi represents the basic structure that will exist on the DAG graph 16 // There may be many implementations of Txi so that the graph structure can support multiple tx types. 17 // Note: All fields not related to graph strcuture should be implemented in their own struct, not interface 18 type Txi interface { 19 // Implemented by TxBase 20 GetType() TxBaseType 21 GetHeight() uint64 22 SetHeight(uint64) 23 GetWeight() uint64 24 SetWeight(weight uint64) 25 GetHash() types.Hash 26 GetParents() types.Hashes // GetParents returns the common.Hash of txs that it directly proves. 27 SetParents(hashes types.Hashes) 28 String() string 29 30 CalculateWeight(parents Txis) uint64 31 Compare(tx Txi) bool // Compare compares two txs, return true if they are the same. 32 SignatureTargets() []byte // SignatureTargets only returns the parts that needs to be signed by sender. 33 GetNonce() uint64 34 35 SetMineNonce(uint64) 36 37 SetHash(h types.Hash) 38 SetValid(b bool) 39 Valid() bool 40 41 // implemented by each tx type 42 //GetBase() *TxBase 43 Sender() common.Address 44 //GetSender() *common.Address 45 SetSender(addr common.Address) 46 //Dump() string // For logger dump 47 48 //RawTxi() RawTxi // compressed txi 49 50 //GetVersion() byte 51 //IsVerified() VerifiedType 52 //SetVerified(v VerifiedType) 53 } 54 55 type Hashable interface { 56 CalcTxHash() types.Hash // TxHash returns a full tx common.Hash (parents sealed by PoW stage 2) 57 } 58 59 type Signable interface { 60 SignatureTargets() []byte 61 } 62 63 type Dumpable interface { 64 Dump() string 65 }