forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipe.go
85 lines (78 loc) · 3.53 KB
/
pipe.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
// Copyright 2017 Monax Industries Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package definitions
// TODO: [ben] This respects the old Pipe interface from burrow.
// This made sense as a wrapper around the old Tendermint, but now
// it strongly reflects the internal details of old Tendermint outwards
// and provides little value as an abstraction.
// The refactor needed here for burrow-0.12.1 is to expose a language
// of transactions, block verification and accounts, grouping
// these interfaces into an Engine, Communicator, NameReg, Permissions (suggestion)
import (
account "github.com/hyperledger/burrow/account"
blockchain_types "github.com/hyperledger/burrow/blockchain/types"
consensus_types "github.com/hyperledger/burrow/consensus/types"
core_types "github.com/hyperledger/burrow/core/types"
types "github.com/hyperledger/burrow/core/types"
event "github.com/hyperledger/burrow/event"
logging_types "github.com/hyperledger/burrow/logging/types"
manager_types "github.com/hyperledger/burrow/manager/types"
"github.com/hyperledger/burrow/txs"
)
type Pipe interface {
Accounts() Accounts
Blockchain() blockchain_types.Blockchain
Events() event.EventEmitter
NameReg() NameReg
Transactor() Transactor
// Hash of Genesis state
GenesisHash() []byte
Logger() logging_types.InfoTraceLogger
// NOTE: [ben] added to Pipe interface on 0.12 refactor
GetApplication() manager_types.Application
SetConsensusEngine(consensusEngine consensus_types.ConsensusEngine) error
GetConsensusEngine() consensus_types.ConsensusEngine
SetBlockchain(blockchain blockchain_types.Blockchain) error
GetBlockchain() blockchain_types.Blockchain
// Support for Tendermint RPC
GetTendermintPipe() (TendermintPipe, error)
}
type Accounts interface {
GenPrivAccount() (*account.PrivAccount, error)
GenPrivAccountFromKey(privKey []byte) (*account.PrivAccount, error)
Accounts([]*event.FilterData) (*types.AccountList, error)
Account(address []byte) (*account.Account, error)
Storage(address []byte) (*types.Storage, error)
StorageAt(address, key []byte) (*types.StorageItem, error)
}
type NameReg interface {
Entry(key string) (*core_types.NameRegEntry, error)
Entries([]*event.FilterData) (*types.ResultListNames, error)
}
type Transactor interface {
Call(fromAddress, toAddress, data []byte) (*types.Call, error)
CallCode(fromAddress, code, data []byte) (*types.Call, error)
// Send(privKey, toAddress []byte, amount int64) (*types.Receipt, error)
// SendAndHold(privKey, toAddress []byte, amount int64) (*types.Receipt, error)
BroadcastTx(tx txs.Tx) (*txs.Receipt, error)
Transact(privKey, address, data []byte, gasLimit,
fee int64) (*txs.Receipt, error)
TransactAndHold(privKey, address, data []byte, gasLimit,
fee int64) (*txs.EventDataCall, error)
Send(privKey, toAddress []byte, amount int64) (*txs.Receipt, error)
SendAndHold(privKey, toAddress []byte, amount int64) (*txs.Receipt, error)
TransactNameReg(privKey []byte, name, data string, amount,
fee int64) (*txs.Receipt, error)
SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error)
}