upgrade web3.js with _extend support
This commit is contained in:
		
							parent
							
								
									1fe617fa57
								
							
						
					
					
						commit
						7584e68c21
					
				| @ -16,7 +16,7 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| 	AdminVersion    = "1.0.0" | 	AdminApiversion = "1.0" | ||||||
| 	importBatchSize = 2500 | 	importBatchSize = 2500 | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| @ -82,6 +82,10 @@ func (self *adminApi) Name() string { | |||||||
| 	return AdminApiName | 	return AdminApiName | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (self *adminApi) ApiVersion() string { | ||||||
|  | 	return AdminApiversion | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (self *adminApi) AddPeer(req *shared.Request) (interface{}, error) { | func (self *adminApi) AddPeer(req *shared.Request) (interface{}, error) { | ||||||
| 	args := new(AddPeerArgs) | 	args := new(AddPeerArgs) | ||||||
| 	if err := self.codec.Decode(req.Params, &args); err != nil { | 	if err := self.codec.Decode(req.Params, &args); err != nil { | ||||||
| @ -215,8 +219,14 @@ func (self *adminApi) Verbosity(req *shared.Request) (interface{}, error) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (self *adminApi) ChainSyncStatus(req *shared.Request) (interface{}, error) { | func (self *adminApi) ChainSyncStatus(req *shared.Request) (interface{}, error) { | ||||||
| 	pending, cached := self.ethereum.Downloader().Stats() | 	pending, cached, importing, estimate := self.ethereum.Downloader().Stats() | ||||||
| 	return map[string]interface{}{"blocksAvailable": pending, "blocksWaitingForImport": cached}, nil | 
 | ||||||
|  | 	return map[string]interface{}{ | ||||||
|  | 		"blocksAvailable": pending, | ||||||
|  | 		"blocksWaitingForImport": cached, | ||||||
|  | 		"importing": importing, | ||||||
|  | 		"estimate": estimate.String(), | ||||||
|  | 	}, nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (self *adminApi) SetSolc(req *shared.Request) (interface{}, error) { | func (self *adminApi) SetSolc(req *shared.Request) (interface{}, error) { | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ import ( | |||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| const ( | const ( | ||||||
| 	DebugVersion = "1.0.0" | 	DebugApiVersion = "1.0" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
| @ -74,6 +74,10 @@ func (self *debugApi) Name() string { | |||||||
| 	return DebugApiName | 	return DebugApiName | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (self *debugApi) ApiVersion() string { | ||||||
|  | 	return DebugApiVersion | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (self *debugApi) PrintBlock(req *shared.Request) (interface{}, error) { | func (self *debugApi) PrintBlock(req *shared.Request) (interface{}, error) { | ||||||
| 	args := new(BlockNumArg) | 	args := new(BlockNumArg) | ||||||
| 	if err := self.codec.Decode(req.Params, &args); err != nil { | 	if err := self.codec.Decode(req.Params, &args); err != nil { | ||||||
| @ -100,7 +104,7 @@ func (self *debugApi) DumpBlock(req *shared.Request) (interface{}, error) { | |||||||
| 		return nil, nil | 		return nil, nil | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return stateDb.Dump(), nil | 	return stateDb.RawDump(), nil | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (self *debugApi) GetBlockRlp(req *shared.Request) (interface{}, error) { | func (self *debugApi) GetBlockRlp(req *shared.Request) (interface{}, error) { | ||||||
|  | |||||||
| @ -39,6 +39,13 @@ web3._extend({ | |||||||
| 			params: 1, | 			params: 1, | ||||||
| 			inputFormatter: [web3._extend.formatters.formatInputInt], | 			inputFormatter: [web3._extend.formatters.formatInputInt], | ||||||
| 			outputFormatter: web3._extend.formatters.formatOutputString | 			outputFormatter: web3._extend.formatters.formatOutputString | ||||||
|  | 		})		, | ||||||
|  | 		new web3._extend.Method({ | ||||||
|  | 			name: 'dumpBlock', | ||||||
|  | 			call: 'debug_dumpBlock', | ||||||
|  | 			params: 1, | ||||||
|  | 			inputFormatter: [web3._extend.formatters.formatInputInt], | ||||||
|  | 			outputFormatter: function(obj) { return obj; } | ||||||
| 		}) | 		}) | ||||||
| 	], | 	], | ||||||
| 	properties: | 	properties: | ||||||
|  | |||||||
| @ -10,6 +10,10 @@ import ( | |||||||
| 	"github.com/ethereum/go-ethereum/xeth" | 	"github.com/ethereum/go-ethereum/xeth" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | const ( | ||||||
|  | 	PersonalApiVersion = "1.0" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| var ( | var ( | ||||||
| 	// mapping between methods and handlers
 | 	// mapping between methods and handlers
 | ||||||
| 	personalMapping = map[string]personalhandler{ | 	personalMapping = map[string]personalhandler{ | ||||||
| @ -65,6 +69,10 @@ func (self *personalApi) Name() string { | |||||||
| 	return PersonalApiName | 	return PersonalApiName | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (self *personalApi) ApiVersion() string { | ||||||
|  | 	return PersonalApiVersion | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (self *personalApi) ListAccounts(req *shared.Request) (interface{}, error) { | func (self *personalApi) ListAccounts(req *shared.Request) (interface{}, error) { | ||||||
| 	return self.xeth.Accounts(), nil | 	return self.xeth.Accounts(), nil | ||||||
| } | } | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ web3._extend({ | |||||||
| 	properties: | 	properties: | ||||||
| 	[ | 	[ | ||||||
| 		new web3._extend.Property({ | 		new web3._extend.Property({ | ||||||
| 			name: 'accounts', | 			name: 'listAccounts', | ||||||
| 			getter: 'personal_listAccounts', | 			getter: 'personal_listAccounts', | ||||||
| 			outputFormatter: function(obj) { return obj; } | 			outputFormatter: function(obj) { return obj; } | ||||||
| 		}) | 		}) | ||||||
|  | |||||||
| @ -9,6 +9,10 @@ import ( | |||||||
| 	"github.com/ethereum/go-ethereum/xeth" | 	"github.com/ethereum/go-ethereum/xeth" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | const ( | ||||||
|  | 	ShhApiVersion = "1.0" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| var ( | var ( | ||||||
| 	// mapping between methods and handlers
 | 	// mapping between methods and handlers
 | ||||||
| 	shhMapping = map[string]shhhandler{ | 	shhMapping = map[string]shhhandler{ | ||||||
| @ -71,6 +75,10 @@ func (self *shhApi) Name() string { | |||||||
| 	return ShhApiName | 	return ShhApiName | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (self *shhApi) ApiVersion() string { | ||||||
|  | 	return ShhApiVersion | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (self *shhApi) Version(req *shared.Request) (interface{}, error) { | func (self *shhApi) Version(req *shared.Request) (interface{}, error) { | ||||||
| 	w := self.xeth.Whisper() | 	w := self.xeth.Whisper() | ||||||
| 	if w == nil { | 	if w == nil { | ||||||
|  | |||||||
| @ -7,6 +7,10 @@ import ( | |||||||
| 	"github.com/ethereum/go-ethereum/xeth" | 	"github.com/ethereum/go-ethereum/xeth" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | const ( | ||||||
|  | 	TxPoolApiVersion = "1.0" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| var ( | var ( | ||||||
| 	// mapping between methods and handlers
 | 	// mapping between methods and handlers
 | ||||||
| 	txpoolMapping = map[string]txpoolhandler{ | 	txpoolMapping = map[string]txpoolhandler{ | ||||||
| @ -59,6 +63,10 @@ func (self *txPoolApi) Name() string { | |||||||
| 	return TxPoolApiName | 	return TxPoolApiName | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (self *txPoolApi) ApiVersion() string { | ||||||
|  | 	return TxPoolApiVersion | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (self *txPoolApi) Status(req *shared.Request) (interface{}, error) { | func (self *txPoolApi) Status(req *shared.Request) (interface{}, error) { | ||||||
| 	return map[string]int{ | 	return map[string]int{ | ||||||
| 		"pending": self.ethereum.TxPool().GetTransactions().Len(), | 		"pending": self.ethereum.TxPool().GetTransactions().Len(), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user