-
Notifications
You must be signed in to change notification settings - Fork 13
/
poa.go
42 lines (32 loc) · 1.12 KB
/
poa.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
package state
import (
"strings"
"github.com/ethereum/go-ethereum/accounts/abi"
eth_common "github.com/ethereum/go-ethereum/common"
)
/*
The POA smart-contract needs to implement a very simple interface. The only
required method is: checkAuthorised(address) bool
*/
const defaultPOAABI = "[{\"type\":\"function\",\"inputs\": [{\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"checkAuthorised\",\"outputs\": [{\"name\":\"\",\"type\":\"bool\"}]}]"
const defaultPOAADDR = "0XABBAABBAABBAABBAABBAABBAABBAABBAABBAABBA"
var (
// POAABI defines the ABI of the POA smart-contract as needed by a consensus
// module to check if an address is authorized
POAABI abi.ABI
// POAABISTRING is the string representaion of POAABI
POAABISTRING string
// POAADDR is the address of the POA smart-contract.
POAADDR eth_common.Address
)
func init() {
POAABI, _ = abi.JSON(strings.NewReader(defaultPOAABI))
POAADDR = eth_common.HexToAddress(defaultPOAADDR)
}
func setPOAABI(poaABI string) {
POAABISTRING = poaABI
POAABI, _ = abi.JSON(strings.NewReader(poaABI))
}
func setPOAADDR(address string) {
POAADDR = eth_common.HexToAddress(address)
}