Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
a73f0f92
Unverified
Commit
a73f0f92
authored
6 years ago
by
Silas Davis
Browse files
Options
Downloads
Patches
Plain Diff
Provide KeyClient to kernel and account state
Signed-off-by:
Silas Davis
<
silas@monax.io
>
parent
cb8bc156
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/kernel.go
+6
-4
6 additions, 4 deletions
core/kernel.go
rpc/service.go
+25
-13
25 additions, 13 deletions
rpc/service.go
with
31 additions
and
17 deletions
core/kernel.go
+
6
−
4
View file @
a73f0f92
...
...
@@ -32,6 +32,7 @@ import (
"github.com/hyperledger/burrow/event"
"github.com/hyperledger/burrow/execution"
"github.com/hyperledger/burrow/genesis"
"github.com/hyperledger/burrow/keys"
"github.com/hyperledger/burrow/logging"
"github.com/hyperledger/burrow/logging/structure"
"github.com/hyperledger/burrow/process"
...
...
@@ -63,9 +64,9 @@ type Kernel struct {
shutdownOnce
sync
.
Once
}
func
NewKernel
(
ctx
context
.
Context
,
privValidator
tm_types
.
PrivValidator
,
genesisDoc
*
genesis
.
GenesisDoc
,
tmConf
*
tm_config
.
Config
,
rpcConfig
*
rpc
.
RPCConfig
,
exeOptions
[]
execution
.
ExecutionOption
,
logger
*
logging
.
Logger
)
(
*
Kernel
,
error
)
{
func
NewKernel
(
ctx
context
.
Context
,
keyClient
keys
.
KeyClient
,
privValidator
tm_types
.
PrivValidator
,
genesisDoc
*
genesis
.
GenesisDoc
,
tmConf
*
tm_config
.
Config
,
rpcConfig
*
rpc
.
RPCConfig
,
exeOptions
[]
execution
.
ExecutionOption
,
logger
*
logging
.
Logger
)
(
*
Kernel
,
error
)
{
logger
=
logger
.
WithScope
(
"NewKernel()"
)
.
With
(
structure
.
TimeKey
,
kitlog
.
DefaultTimestampUTC
)
tmLogger
:=
logger
.
With
(
structure
.
CallerKey
,
kitlog
.
Caller
(
LoggingCallerDepth
+
1
))
...
...
@@ -103,7 +104,8 @@ func NewKernel(ctx context.Context, privValidator tm_types.PrivValidator, genesi
transactor
:=
execution
.
NewTransactor
(
blockchain
,
state
,
emitter
,
tendermint
.
BroadcastTxAsyncFunc
(
tmNode
,
txCodec
),
logger
)
service
:=
rpc
.
NewService
(
ctx
,
state
,
state
,
emitter
,
blockchain
,
transactor
,
query
.
NewNodeView
(
tmNode
,
txCodec
),
logger
)
service
:=
rpc
.
NewService
(
ctx
,
state
,
checker
,
state
,
emitter
,
blockchain
,
keyClient
,
transactor
,
query
.
NewNodeView
(
tmNode
,
txCodec
),
logger
)
launchers
:=
[]
process
.
Launcher
{
{
...
...
This diff is collapsed.
Click to expand it.
rpc/service.go
+
25
−
13
View file @
a73f0f92
...
...
@@ -25,6 +25,7 @@ import (
"github.com/hyperledger/burrow/consensus/tendermint/query"
"github.com/hyperledger/burrow/event"
"github.com/hyperledger/burrow/execution"
"github.com/hyperledger/burrow/keys"
"github.com/hyperledger/burrow/logging"
"github.com/hyperledger/burrow/logging/structure"
"github.com/hyperledger/burrow/permission"
...
...
@@ -41,7 +42,8 @@ const MaxBlockLookback = 100
// Base service that provides implementation for all underlying RPC methods
type
Service
struct
{
ctx
context
.
Context
iterable
state
.
Iterable
committed
*
execution
.
Accounts
mempool
*
execution
.
Accounts
subscribable
event
.
Subscribable
nameReg
execution
.
NameRegIterable
blockchain
bcm
.
Blockchain
...
...
@@ -50,13 +52,15 @@ type Service struct {
logger
*
logging
.
Logger
}
func
NewService
(
ctx
context
.
Context
,
iterable
state
.
Iterable
,
nameReg
execution
.
NameRegIterable
,
subscribable
event
.
Subscribable
,
blockchain
bcm
.
Blockchain
,
transactor
*
execution
.
Transactor
,
nodeView
query
.
NodeView
,
logger
*
logging
.
Logger
)
*
Service
{
func
NewService
(
ctx
context
.
Context
,
committedState
state
.
Iterable
,
mempoolState
state
.
Iterable
,
nameReg
execution
.
NameRegIterable
,
subscribable
event
.
Subscribable
,
blockchain
bcm
.
Blockchain
,
keyClient
keys
.
KeyClient
,
transactor
*
execution
.
Transactor
,
nodeView
query
.
NodeView
,
logger
*
logging
.
Logger
)
*
Service
{
return
&
Service
{
ctx
:
ctx
,
iterable
:
iterable
,
committed
:
execution
.
NewAccounts
(
committedState
,
keyClient
),
mempool
:
execution
.
NewAccounts
(
mempoolState
,
keyClient
),
nameReg
:
nameReg
,
subscribable
:
subscribable
,
blockchain
:
blockchain
,
...
...
@@ -81,6 +85,14 @@ func (s *Service) Transactor() *execution.Transactor {
return
s
.
transactor
}
func
(
s
*
Service
)
Committed
()
*
execution
.
Accounts
{
return
s
.
committed
}
func
(
s
*
Service
)
Mempool
()
*
execution
.
Accounts
{
return
s
.
mempool
}
func
(
s
*
Service
)
ListUnconfirmedTxs
(
maxTxs
int
)
(
*
ResultListUnconfirmedTxs
,
error
)
{
// Get all transactions for now
transactions
,
err
:=
s
.
nodeView
.
MempoolTransactions
(
maxTxs
)
...
...
@@ -180,7 +192,7 @@ func (s *Service) Peers() (*ResultPeers, error) {
func
(
s
*
Service
)
NetInfo
()
(
*
ResultNetInfo
,
error
)
{
listening
:=
s
.
nodeView
.
IsListening
()
listeners
:=
[]
string
{}
var
listeners
[]
string
for
_
,
listener
:=
range
s
.
nodeView
.
Listeners
()
{
listeners
=
append
(
listeners
,
listener
.
String
())
}
...
...
@@ -203,7 +215,7 @@ func (s *Service) Genesis() (*ResultGenesis, error) {
// Accounts
func
(
s
*
Service
)
GetAccount
(
address
acm
.
Address
)
(
*
ResultGetAccount
,
error
)
{
acc
,
err
:=
s
.
iterable
.
GetAccount
(
address
)
acc
,
err
:=
s
.
committed
.
GetAccount
(
address
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -215,7 +227,7 @@ func (s *Service) GetAccount(address acm.Address) (*ResultGetAccount, error) {
func
(
s
*
Service
)
ListAccounts
(
predicate
func
(
acm
.
Account
)
bool
)
(
*
ResultListAccounts
,
error
)
{
accounts
:=
make
([]
*
acm
.
ConcreteAccount
,
0
)
s
.
iterable
.
IterateAccounts
(
func
(
account
acm
.
Account
)
(
stop
bool
)
{
s
.
committed
.
IterateAccounts
(
func
(
account
acm
.
Account
)
(
stop
bool
)
{
if
predicate
(
account
)
{
accounts
=
append
(
accounts
,
acm
.
AsConcreteAccount
(
account
))
}
...
...
@@ -229,7 +241,7 @@ func (s *Service) ListAccounts(predicate func(acm.Account) bool) (*ResultListAcc
}
func
(
s
*
Service
)
GetStorage
(
address
acm
.
Address
,
key
[]
byte
)
(
*
ResultGetStorage
,
error
)
{
account
,
err
:=
s
.
iterable
.
GetAccount
(
address
)
account
,
err
:=
s
.
committed
.
GetAccount
(
address
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -237,7 +249,7 @@ func (s *Service) GetStorage(address acm.Address, key []byte) (*ResultGetStorage
return
nil
,
fmt
.
Errorf
(
"UnknownAddress: %s"
,
address
)
}
value
,
err
:=
s
.
iterable
.
GetStorage
(
address
,
binary
.
LeftPadWord256
(
key
))
value
,
err
:=
s
.
committed
.
GetStorage
(
address
,
binary
.
LeftPadWord256
(
key
))
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -248,7 +260,7 @@ func (s *Service) GetStorage(address acm.Address, key []byte) (*ResultGetStorage
}
func
(
s
*
Service
)
DumpStorage
(
address
acm
.
Address
)
(
*
ResultDumpStorage
,
error
)
{
account
,
err
:=
s
.
iterable
.
GetAccount
(
address
)
account
,
err
:=
s
.
committed
.
GetAccount
(
address
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -256,7 +268,7 @@ func (s *Service) DumpStorage(address acm.Address) (*ResultDumpStorage, error) {
return
nil
,
fmt
.
Errorf
(
"UnknownAddress: %X"
,
address
)
}
var
storageItems
[]
StorageItem
s
.
iterable
.
IterateStorage
(
address
,
func
(
key
,
value
binary
.
Word256
)
(
stop
bool
)
{
s
.
committed
.
IterateStorage
(
address
,
func
(
key
,
value
binary
.
Word256
)
(
stop
bool
)
{
storageItems
=
append
(
storageItems
,
StorageItem
{
Key
:
key
.
UnpadLeft
(),
Value
:
value
.
UnpadLeft
()})
return
})
...
...
@@ -267,7 +279,7 @@ func (s *Service) DumpStorage(address acm.Address) (*ResultDumpStorage, error) {
}
func
(
s
*
Service
)
GetAccountHumanReadable
(
address
acm
.
Address
)
(
*
ResultGetAccountHumanReadable
,
error
)
{
acc
,
err
:=
s
.
iterable
.
GetAccount
(
address
)
acc
,
err
:=
s
.
committed
.
GetAccount
(
address
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment