/
abc.go
45 lines (36 loc) · 1.27 KB
/
abc.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
package rpc
import (
"fmt"
"github.com/copernet/copernicus/conf"
"strconv"
"github.com/copernet/copernicus/model/consensus"
"github.com/copernet/copernicus/rpc/btcjson"
)
var abcHandlers = map[string]commandHandler{
"getexcessiveblock": handleGetExcessiveBlock,
"setexcessiveblock": handleSetExcessiveBlock,
}
func handleGetExcessiveBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
return &btcjson.ExcessiveBlockSizeResult{
ExcessiveBlockSize: conf.Cfg.Excessiveblocksize,
}, nil
}
func handleSetExcessiveBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
c := cmd.(*btcjson.SetExcessiveBlockCmd)
// Do not allow maxBlockSize to be set below historic 1MB limit
if c.BlockSize <= consensus.LegacyMaxBlockSize {
return nil, &btcjson.RPCError{
Code: btcjson.ErrRPCInvalidParameter,
Message: "Invalid parameter, excessiveblock must be larger than " + strconv.Itoa(consensus.LegacyMaxBlockSize),
}
}
// Set the new max block size.
conf.Cfg.Excessiveblocksize = c.BlockSize
// settingsToUserAgentString();
return "Excessive Block set to " + fmt.Sprintf("%d", c.BlockSize) + " bytes", nil
}
func registerABCRPCCommands() {
for name, handler := range abcHandlers {
appendCommand(name, handler)
}
}