forked from OpenAtomFoundation/xupercore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.go
39 lines (35 loc) · 1.3 KB
/
context.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
// 明确定义该模块需要的上下文信息,方便代码阅读和理解
package context
import (
"github.com/superconsensus/matrixcore/kernel/common/xaddress"
xctx "github.com/superconsensus/matrixcore/kernel/common/xcontext"
"github.com/superconsensus/matrixcore/kernel/contract"
"github.com/superconsensus/matrixcore/kernel/ledger"
"github.com/superconsensus/matrixcore/kernel/network"
cryptoBase "github.com/superconsensus/matrixcore/lib/crypto/client/base"
)
type BlockInterface ledger.BlockHandle
type Address xaddress.Address
type CryptoClient cryptoBase.CryptoClient
type P2pCtxInConsensus network.Network
// LedgerCtxInConsensus使用到的ledger接口
type LedgerRely interface {
GetConsensusConf() ([]byte, error)
QueryBlockHeader(blkId []byte) (ledger.BlockHandle, error)
QueryBlockHeaderByHeight(int64) (ledger.BlockHandle, error)
GetTipBlock() ledger.BlockHandle
GetTipXMSnapshotReader() (ledger.XMSnapshotReader, error)
CreateSnapshot(blkId []byte) (ledger.XMReader, error)
GetTipSnapshot() (ledger.XMReader, error)
QueryTipBlockHeader() ledger.BlockHandle
}
// ConsensusCtx共识运行环境上下文
type ConsensusCtx struct {
xctx.BaseCtx
BcName string
Address *Address
Crypto cryptoBase.CryptoClient
Contract contract.Manager
Ledger LedgerRely
Network network.Network
}