Documentation
¶
Index ¶
- Constants
- func Init()
- type BatchService
- type BlockService
- type ConsensusService
- type EventBatcherServiceImpl
- type Handle
- type LeaderElectionService
- type Ledger
- func (l *Ledger) AddBlock(blk *domain.Block) (bool, error)
- func (l *Ledger) Close()
- func (l *Ledger) CreateBlock(txList []*domain.Transaction, createPeerId string) (*domain.Block, error)
- func (l *Ledger) CreateGenesisBlock() (*domain.Block, error)
- func (l *Ledger) GetLastBlock() (*domain.Block, error)
- func (l *Ledger) LookUpBlock(arg interface{}) (*domain.Block, error)
- func (l *Ledger) VerifyBlock(blk *domain.Block) (bool, error)
- type PBFTConsensusService
- func (cs *PBFTConsensusService) EndConsensusState(consensusState *domain.ConsensusState)
- func (cs *PBFTConsensusService) GetCurrentConsensusState() map[string]*domain.ConsensusState
- func (cs *PBFTConsensusService) ReceiveConsensusMessage(msg msg.OutterMessage)
- func (cs *PBFTConsensusService) StartConsensus(view *domain.View, block *domain.Block)
- func (cs *PBFTConsensusService) StopConsensus()
- type PeerService
- type PeerServiceImpl
- func (ps *PeerServiceImpl) AddPeer(Peer *domain.Peer)
- func (ps *PeerServiceImpl) BroadCastPeerTable(interface{})
- func (ps *PeerServiceImpl) GetLeader() *domain.Peer
- func (ps *PeerServiceImpl) GetPeerByPeerID(peerID string) *domain.Peer
- func (ps *PeerServiceImpl) GetPeerTable() *domain.PeerTable
- func (ps *PeerServiceImpl) HandleOnConnect(conn conn.Connection, pp pb.Peer)
- func (ps *PeerServiceImpl) PushPeerTable(peerIDs []string)
- func (ps *PeerServiceImpl) RequestPeer(ip string) (*domain.Peer, error)
- func (ps *PeerServiceImpl) SetLeader(peer *domain.Peer)
- func (ps *PeerServiceImpl) UpdatePeerTable(peerTable domain.PeerTable)
- type RAFTelectionService
- type SmartContract
- type SmartContractService
- type SmartContractServiceImpl
- func (scs *SmartContractServiceImpl) Deploy(ReposPath string) (string, error)
- func (scs *SmartContractServiceImpl) Invoke(transaction *domain.Transaction) (*domain.SmartContractResponse, error)
- func (scs *SmartContractServiceImpl) PullAllSmartContracts(errorHandler func(error), completionHandler func())
- func (scs *SmartContractServiceImpl) Query()
- func (scs *SmartContractServiceImpl) RunTransaction(transaction *domain.Transaction) error
- func (scs *SmartContractServiceImpl) RunTransactionOnDocker(transaction *domain.Transaction) (*domain.SmartContractResponse, error)
- func (scs *SmartContractServiceImpl) RunTransactionsOfBlock(block domain.Block) error
- func (scs *SmartContractServiceImpl) ValidateTransaction(transaction *domain.Transaction)
- func (scs *SmartContractServiceImpl) ValidateTransactionsOfBlock(block *domain.Block) error
- type TransactionService
- type TransactionServiceImpl
- func (t *TransactionServiceImpl) AddTransaction(tx *domain.Transaction) error
- func (t *TransactionServiceImpl) Close()
- func (t *TransactionServiceImpl) CreateTransaction(txData *domain.TxData) (*domain.Transaction, error)
- func (t *TransactionServiceImpl) DeleteTransactions(txs []*domain.Transaction) error
- func (t *TransactionServiceImpl) GetTransactions(limit int) ([]*domain.Transaction, error)
- func (t *TransactionServiceImpl) SendToLeader(interface{})
Constants ¶
const (
WAITING_TRANSACTION = "waiting_transaction"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BatchService ¶
type BatchService interface {
Start()
// Add adds a protos to be batched
Add(interface{})
// Stop stops the component
Stop()
// Size returns the amount of pending messages to be emitted
Size() int
}
func NewBatchService ¶
func NewBatchService(period time.Duration, handle Handle, deleting bool) BatchService
batcher T시간 간격으로 handler에게 메세지를 전달해준다 deleting option에 따라서 전달한 message를 지울껀지 아니면 계속 남겨둘지를 설정한다. buff: protos queue lock: sync period: T time stopflag: to stop batcher handler: messaging handler
type BlockService ¶
type BlockService interface {
// Confirmed 된 블록 추가
AddBlock(blk *domain.Block) (bool, error)
// DB close
Close()
// Block Chain의 마지막 블록을 반환
GetLastBlock() (*domain.Block, error)
// 블록을 검증
VerifyBlock(blk *domain.Block) (bool, error)
// 블록 조회
LookUpBlock(arg interface{}) (*domain.Block, error)
// 블록 생성
CreateBlock(txList []*domain.Transaction, createPeerId string) (*domain.Block, error)
}
func NewLedger ¶
func NewLedger(path string) BlockService
type ConsensusService ¶
type ConsensusService interface {
//Consensus 시작
StartConsensus(view *domain.View, block *domain.Block)
StopConsensus()
//consensus메세지는 모두 이쪽으로 받는다.
ReceiveConsensusMessage(message msg.OutterMessage)
GetCurrentConsensusState() map[string]*domain.ConsensusState
}
func NewPBFTConsensusService ¶
func NewPBFTConsensusService(comm comm.ConnectionManager, webHookService webhook.WebhookService, peerService PeerService, blockService BlockService, identity *domain.Peer, smartContractService SmartContractService, transactionService TransactionService) ConsensusService
type EventBatcherServiceImpl ¶
type EventBatcherServiceImpl struct {
Period time.Duration
// contains filtered or unexported fields
}
func (*EventBatcherServiceImpl) Add ¶
func (gb *EventBatcherServiceImpl) Add(message interface{})
tested
func (*EventBatcherServiceImpl) Start ¶
func (gb *EventBatcherServiceImpl) Start()
type LeaderElectionService ¶
type LeaderElectionService interface {
// 시작
Run()
// 종료
Stop()
// HeartBeat, Request Vote Massage, Vote 메세지 Receive
ReceiveMessage(message msg.OutterMessage)
// 리더 선출 서비스에 피어를 추가
AddPeerId()
// DB로 부터 마지막 블록의 해시값을 가져옴
GetLastBlockHash() string
}
func NewRAFTelectionService ¶
func NewRAFTelectionService(comm comm.ConnectionManager, peerID string) LeaderElectionService
type PBFTConsensusService ¶
todo peerID를 어디서 가져올 것인가??
func (*PBFTConsensusService) EndConsensusState ¶
func (cs *PBFTConsensusService) EndConsensusState(consensusState *domain.ConsensusState)
func (*PBFTConsensusService) GetCurrentConsensusState ¶
func (cs *PBFTConsensusService) GetCurrentConsensusState() map[string]*domain.ConsensusState
func (*PBFTConsensusService) ReceiveConsensusMessage ¶
func (cs *PBFTConsensusService) ReceiveConsensusMessage(msg msg.OutterMessage)
consensusMessage가 들어옴 todo FromConsensusProtoMessage에서 block변환도 해야함 todo time을 config로 부터 읽어야함 todo 다음 block이 먼저 들어올 경우 고려해야함, todo 블록의 높이와 이전 블록 해시가 올바른지 확인
func (*PBFTConsensusService) StartConsensus ¶
func (cs *PBFTConsensusService) StartConsensus(view *domain.View, block *domain.Block)
tested Consensus 시작 만약 합의에 들어가는 peerID가 없다면 바로 block에 저장 1. Consensus의 state를 추가한다. 2. 합의할 block을 consensusMessage에 담고 prepreMsg로 전파한다.
func (*PBFTConsensusService) StopConsensus ¶
func (cs *PBFTConsensusService) StopConsensus()
type PeerService ¶
type PeerService interface {
//peer table 조회
GetPeerTable() *domain.PeerTable
//peer info 찾기
GetPeerByPeerID(peerID string) *domain.Peer
//peer info
PushPeerTable(peerIDs []string)
//update peerTable
UpdatePeerTable(peerTable domain.PeerTable)
//Add peer
AddPeer(Peer *domain.Peer)
//Request Peer Info
RequestPeer(ip string) (*domain.Peer, error)
BroadCastPeerTable(interface{})
GetLeader() *domain.Peer
SetLeader(peer *domain.Peer)
}
peer 최상위 service
func NewPeerServiceImpl ¶
func NewPeerServiceImpl(peerTable *domain.PeerTable, comm comm.ConnectionManager) PeerService
type PeerServiceImpl ¶
type PeerServiceImpl struct {
// contains filtered or unexported fields
}
func (*PeerServiceImpl) AddPeer ¶
func (ps *PeerServiceImpl) AddPeer(Peer *domain.Peer)
func (*PeerServiceImpl) BroadCastPeerTable ¶
func (ps *PeerServiceImpl) BroadCastPeerTable(interface{})
주기적으로 handle 함수가 콜 된다. 주기적으로 peerTable의 peerlist에게 peerTable을 전송한다.
func (*PeerServiceImpl) GetLeader ¶
func (ps *PeerServiceImpl) GetLeader() *domain.Peer
func (*PeerServiceImpl) GetPeerByPeerID ¶
func (ps *PeerServiceImpl) GetPeerByPeerID(peerID string) *domain.Peer
peer info 찾기
func (*PeerServiceImpl) GetPeerTable ¶
func (ps *PeerServiceImpl) GetPeerTable() *domain.PeerTable
func (*PeerServiceImpl) HandleOnConnect ¶
func (ps *PeerServiceImpl) HandleOnConnect(conn conn.Connection, pp pb.Peer)
func (*PeerServiceImpl) PushPeerTable ¶
func (ps *PeerServiceImpl) PushPeerTable(peerIDs []string)
peer info
func (*PeerServiceImpl) RequestPeer ¶
func (ps *PeerServiceImpl) RequestPeer(ip string) (*domain.Peer, error)
func (*PeerServiceImpl) SetLeader ¶
func (ps *PeerServiceImpl) SetLeader(peer *domain.Peer)
func (*PeerServiceImpl) UpdatePeerTable ¶
func (ps *PeerServiceImpl) UpdatePeerTable(peerTable domain.PeerTable)
type RAFTelectionService ¶
func (*RAFTelectionService) AddPeerId ¶
func (r *RAFTelectionService) AddPeerId()
func (*RAFTelectionService) GetLastBlockHash ¶
func (r *RAFTelectionService) GetLastBlockHash() string
func (*RAFTelectionService) ReceiveMessage ¶
func (r *RAFTelectionService) ReceiveMessage(message msg.OutterMessage)
별로의 무한루프 쓰레드열고 채널로 데이터 메세지가 들어오면 리시브 메세지가 메세지를 받아서 처리하는 것인지 comm 찾아보고 결정
func (*RAFTelectionService) Run ¶
func (r *RAFTelectionService) Run()
func (*RAFTelectionService) Stop ¶
func (r *RAFTelectionService) Stop()
type SmartContract ¶
type SmartContractService ¶
type SmartContractService interface {
Invoke(transaction *domain.Transaction) (*domain.SmartContractResponse, error)
Query()
Deploy(ReposPath string) (string, error)
PullAllSmartContracts(authenticatedGit string, errorHandler func(error), completionHandler func())
ValidateTransactionsOfBlock(block *domain.Block) error
ValidateTransaction(transaction *domain.Transaction)
}
peer 최상위 service
type SmartContractServiceImpl ¶
type SmartContractServiceImpl struct {
GithubID string
SmartContractHomePath string
SmartContractMap map[string]SmartContract
WorldStateDBPath string
WorldStateDBName string
}
func NewSmartContractService ¶
func NewSmartContractService(githubID string, smartContractDirPath string) *SmartContractServiceImpl
func (*SmartContractServiceImpl) Deploy ¶
func (scs *SmartContractServiceImpl) Deploy(ReposPath string) (string, error)
func (*SmartContractServiceImpl) Invoke ¶
func (scs *SmartContractServiceImpl) Invoke(transaction *domain.Transaction) (*domain.SmartContractResponse, error)
func (*SmartContractServiceImpl) PullAllSmartContracts ¶
func (scs *SmartContractServiceImpl) PullAllSmartContracts(errorHandler func(error), completionHandler func())
func (*SmartContractServiceImpl) Query ¶
func (scs *SmartContractServiceImpl) Query()
func (*SmartContractServiceImpl) RunTransaction ¶
func (scs *SmartContractServiceImpl) RunTransaction(transaction *domain.Transaction) error
func (*SmartContractServiceImpl) RunTransactionOnDocker ¶
func (scs *SmartContractServiceImpl) RunTransactionOnDocker(transaction *domain.Transaction) (*domain.SmartContractResponse, error)
func (*SmartContractServiceImpl) RunTransactionsOfBlock ¶
func (scs *SmartContractServiceImpl) RunTransactionsOfBlock(block domain.Block) error
func (*SmartContractServiceImpl) ValidateTransaction ¶
func (scs *SmartContractServiceImpl) ValidateTransaction(transaction *domain.Transaction)
func (*SmartContractServiceImpl) ValidateTransactionsOfBlock ¶
func (scs *SmartContractServiceImpl) ValidateTransactionsOfBlock(block *domain.Block) error
**************************************************
- 1. smartcontract 검사
- 2. smartcontract -> sc.tar : 애초에 풀 받을 때 압축해 둘 수 있음
- 3. go 버전에 맞는 docker image를 Create
- 4. sc.tar를 docker container로 복사
- 5. docker container Start
- 6. docker에서 smartcontract 실행 ***************************************************
type TransactionService ¶
type TransactionService interface {
AddTransaction(tx *domain.Transaction) error
DeleteTransactions(txs []*domain.Transaction) error
GetTransactions(limit int) ([]*domain.Transaction, error)
CreateTransaction(txData *domain.TxData) (*domain.Transaction, error)
}
type TransactionServiceImpl ¶
type TransactionServiceImpl struct {
DB *leveldbhelper.DBProvider
Comm comm.ConnectionManager
PeerService PeerService
}
func NewTransactionService ¶
func NewTransactionService(path string, comm comm.ConnectionManager, ps PeerService) *TransactionServiceImpl
func (*TransactionServiceImpl) AddTransaction ¶
func (t *TransactionServiceImpl) AddTransaction(tx *domain.Transaction) error
func (*TransactionServiceImpl) Close ¶
func (t *TransactionServiceImpl) Close()
func (*TransactionServiceImpl) CreateTransaction ¶
func (t *TransactionServiceImpl) CreateTransaction(txData *domain.TxData) (*domain.Transaction, error)
func (*TransactionServiceImpl) DeleteTransactions ¶
func (t *TransactionServiceImpl) DeleteTransactions(txs []*domain.Transaction) error
func (*TransactionServiceImpl) GetTransactions ¶
func (t *TransactionServiceImpl) GetTransactions(limit int) ([]*domain.Transaction, error)
func (*TransactionServiceImpl) SendToLeader ¶
func (t *TransactionServiceImpl) SendToLeader(interface{})
Source Files
¶
- PBFTconsensus_service_impl.go
- RAFTelection_service.go
- RAFTelection_service_impl.go
- batch_service.go
- batch_service_impl.go
- block_service.go
- block_service_impl.go
- consensus_service.go
- peer_service.go
- peer_service_impl.go
- smart_contract_service.go
- smart_contract_service_impl.go
- transaction_service.go
- transaction_service_impl.go