github.com/annchain/OG@v0.0.9/og_interface/interface.go (about) 1 package og_interface 2 3 import ( 4 "github.com/annchain/OG/consensus_interface" 5 "github.com/libp2p/go-libp2p-core/crypto" 6 ) 7 8 type PeerJoinedEvent struct { 9 PeerId string 10 } 11 type PeerLeftEvent struct { 12 PeerId string 13 } 14 15 type PeerJoinedEventSubscriber interface { 16 EventChannelPeerJoined() chan *PeerJoinedEvent 17 } 18 19 type PeerLeftEventSubscriber interface { 20 EventChannelPeerLeft() chan *PeerLeftEvent 21 } 22 23 type NodeInfoProvider interface { 24 CurrentHeight() int64 25 GetNetworkId() string 26 } 27 28 type NewHeightDetectedEvent struct { 29 Height int64 30 PeerId string 31 } 32 33 type AccountHolder interface { 34 ProvidePrivateKey(createIfMissing bool) ([]byte, error) 35 } 36 type LedgerSigner interface { 37 Sign(msg []byte, account OgLedgerAccount) []byte 38 } 39 40 type NewHeightDetectedEventSubscriber interface { 41 Name() string 42 NewHeightDetectedEventChannel() chan *NewHeightDetectedEvent 43 } 44 45 type LedgerAccountProvider interface { 46 ProvideAccount() (*OgLedgerAccount, error) 47 Generate() (account *OgLedgerAccount, err error) 48 Load() (account *OgLedgerAccount, err error) 49 Save() (err error) 50 } 51 52 type AddressConverter interface { 53 AddressFromAccount(account *OgLedgerAccount) (addr Address, err error) 54 } 55 56 type PrivateGenerator interface { 57 GeneratePair(typ int) (privKey crypto.PrivKey, pubKey crypto.PubKey, err error) 58 } 59 60 type BlockContent interface { 61 GetType() BlockContentType 62 String() string 63 FromString(string) 64 GetHash() Hash 65 GetHeight() int64 66 } 67 68 type Ledger interface { 69 CurrentHeight() int64 70 CurrentCommittee() *consensus_interface.Committee 71 GetBlock(height int64) BlockContent 72 ConfirmBlock(block BlockContent) 73 GetResource(request ResourceRequest) Resource 74 }